How to set the border of UITextView to same as border color of UITextField

前端 未结 8 2062
遇见更好的自我
遇见更好的自我 2020-12-24 10:37

By default UITextField has a light gray color as its border color. I want to set my UITextView to have the same border color as the UITextField.

I tried:

<         


        
8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-24 11:09

    I had this similar question for iOS 10, and wasn't able to find an answer, but this is what I found using the Digital Color Meter in Utilities and the iOS Simulator.

    Swift 3 / iOS 10

    let color = UIColor(red: 186/255, green: 186/255, blue: 186/255, alpha: 1.0).cgColor
    myTextView.layer.borderColor = color
    myTextView.layer.borderWidth = 0.5
    myTextView.layer.cornerRadius = 5
    

提交回复
热议问题