Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the custom border color of UIView programmatically?

Tags:

ios

swift

I am trying to set the custom border color of UIView programmatically in Swift.

like image 202
Shashi Verma Avatar asked Apr 17 '15 13:04

Shashi Verma


People also ask

How do you add a border color in Swift?

You need to set the borderWidth from the UITextField 's layer property. Like: email. layer. borderWidth = 1 .

How do you give border to view in react native?

To set border around view component in react native we have to use borderWidth and borderColor style prop. Using the borderWidth prop we would define the border width in pixels. The borderWidth prop Number type value. The higher value we would pass the thicker border would be.


1 Answers

If you Use Swift 2.0+

self.yourView.layer.borderWidth = 1 self.yourView.layer.borderColor = UIColor(red:222/255, green:225/255, blue:227/255, alpha: 1).cgColor 
like image 181
Shashi Verma Avatar answered Oct 06 '22 02:10

Shashi Verma