0
私のtextFieldに上下の境界線を設定する必要があります。私は知識の不足には申し訳なく思っています。どのように私はどのように私は実行可能なbounds
プロパティこのコード私はTextFieldを作成するtableviewCellクラスで設定することができます助けてください。プロパティ "bounds"がtableviewCellクラスに見つかりません
class NewAdressForGustCell : UITableViewCell{
var areaTextField : RightPaddingTextField = {
var textField = RightPaddingTextField()
let topBorder = CALayer()
topBorder.frame = CGRect(0, 0, bounds.size.width, 1)
topBorder.backgroundColor = UIColor.gray.cgColor
textField.layer.addSublayer(topBorder)
let bottomBorder = CALayer()
bottomBorder.frame = CGRect(0, bounds.size.height-1, bounds.size.width, 1)
bottomBorder.backgroundColor = UIColor.gray.cgColor
textField.layer.addSublayer(bottomBorder)
textField.translatesAutoresizingMaskIntoConstraints = false
return textField
}()
}
。 'self.bounds'が追加されましたが、var areaTextFieldを' lazy'として追加することを忘れました –
はい、両方を行う必要があります。私は私の答えにあなたのコードの作業バージョンを追加しました!編集した回答を確認してください。 – matt
yea私はちょうどあなたの答えを受け入れるのを待っています –