Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the UITextField default borderColor in iOS8?

I have a button with a border that I want to style as a UITextField.

So I tried:

self.dateButton.layer.borderColor = self.assesseeName.layer.borderColor

But that gives me a black border: enter image description here

How do I get the same color as the UITextField (top of screenshot)?

like image 354
Tycho Pandelaar Avatar asked Nov 28 '14 17:11

Tycho Pandelaar


4 Answers

I set the border color for the button to be the standard light gray and the border width to be 0.25 and that matched

Swift 3:

myButton.layer.borderWidth = 0.25
myButton.layer.borderColor = UIColor.lightGray.cgColor
like image 116
user7875087 Avatar answered Nov 06 '22 12:11

user7875087


You can use the following code to apply same effect of textfield to buttton (borderwidth, bordercolor, & corner radius)

UIColor *borderColor = [UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1.0];

dateButton.layer.borderColor = borderColor.CGColor;   
dateButton.layer.borderWidth = 1.0;
dateButton.layer.cornerRadius = 5.0;
like image 29
Pavan Gandhi Avatar answered Nov 06 '22 14:11

Pavan Gandhi


According to the Mac's Digital Color Meter the RGB of the borders is 230, 230, 230.

like image 2
AdvApp Avatar answered Nov 06 '22 13:11

AdvApp


In iOS 13 the color changes between light and dark mode

if #available(iOS 13.0, *) {
    view.layer.borderColor = UIColor(dynamicProvider: { trait in
        if trait.userInterfaceStyle == .light {
            return UIColor(white: 0, alpha: 0.2)
        } else {
            return UIColor(white: 1, alpha: 0.2)
        }
    }).cgColor
} else {

    view.layer.borderColor = UIColor(white: 0, alpha: 0.2).cgColor
}
like image 1
zombie Avatar answered Nov 06 '22 12:11

zombie