Adding UITextField on UIView Programmatically Swift

前端 未结 9 1291
不知归路
不知归路 2021-01-30 06:42

I\'m new to Swift and iOS programming. I was trying to create a UITextField programmatically using Swift but couldn\'t get it quite right. Also how do you change it

9条回答
  •  爱一瞬间的悲伤
    2021-01-30 07:17

    Try below code

    var textFiled = UITextField(frame: CGRectMake(20.0, 30.0, 100.0, 33.0))
            textFiled.backgroundColor = UIColor.redColor()
            textFiled.borderStyle = UITextBorderStyle.Line
            self.view.addSubview(textFiled)
    

提交回复
热议问题