Swift

swift UITextField 、UITextView 实现

2020-06-16  本文已影响0人  江河_ios

UITextField

lazy var textfield : UITextField = {
    let textfield = UITextField.init()
    textfield.frame = CGRect(x: 20, y: 100, width: screenWidth-40, height: 50)
    textfield.placeholder = "请输入你的密码"
    textfield.font = UIFont.systemFont(ofSize: 17)
    textfield.textColor = UIColor.red
    textfield.borderStyle = UITextField.BorderStyle.line
    
    return textfield
}()

UITextView实现

lazy var textView: UITextView = {
    let textView = UITextView.init()
    textView.frame = CGRect(x: 20, y: self.textfield.maxY+20, width: self.textfield.width, height: 200)
    textView.clipsToBounds = true
    textView.textColor = UIColor.orange
    textView.layer.cornerRadius = 10
    textView.layer.borderWidth = 1.0
    textView.layer.borderColor = UIColor.gray.cgColor
    textView.font = UIFont.systemFont(ofSize: 17)
    return textView
}()
上一篇 下一篇

猜你喜欢

热点阅读