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

前端 未结 8 2030
遇见更好的自我
遇见更好的自我 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:17

    As with Swift 5.2 and with dark mode support :)

    If your textField is like:

    myTextField.layer.cornerRadius = 10
    myTextField.layer.borderWidth = 1
    myTextField..layer.borderColor = UIColor.systemGray4.cgColor
    

    then your UITextView will look exactly the same with:

    myTextView.layer.cornerRadius = 10
    myTextView.layer.borderWidth = 1.0
    myTextView.layer.borderColor = UIColor.systemGray4.cgColor
    
    0 讨论(0)
  • 2020-12-24 11:20

    The exact color is:

    Objective-C:

    [UIColor colorWithRed:0.76 green:0.76 blue:0.76 alpha:1.0].CGColor;
    

    Swift:

    UIColor(red:0.76, green:0.76, blue:0.76, alpha:1.0).CGColor
    
    0 讨论(0)
提交回复
热议问题