How do I change the border color of a button?
Asked
Active
Viewed 163 times
-2
-
Check this https://stackoverflow.com/a/48470255/8014650 – arun siva Jun 03 '19 at 17:01
-
yourButton.layer.borderColor = [UIColor redColor]; yourButton.layer.borderWidth = 2.0f; – manishsharma93 Jun 04 '19 at 10:02
2 Answers
1
Take a look at CALayer. Every UIView has a ‘layer’ property on which you can set a borderWidth, color, etc...

Paul van Roosendaal
- 844
- 7
- 18
-
Can i get a code example please? like where in the viewcontroller.swift do i add that code? :S? – Fadel Benhamza Jun 03 '19 at 17:39
-
0
Put inside your viewDidLoad
method inside ViewController:
yourButtonProperty.layer.borderColor = UIColor.black.cgColor
Replace yourButtonProperty
with property for your Button.
Docs for CALayer: https://developer.apple.com/documentation/quartzcore/calayer

Andrei Konstantinov
- 6,971
- 4
- 41
- 57
-
Can i get a code example please? like where in the viewcontroller.swift do i add that code? :S? – Fadel Benhamza Jun 03 '19 at 17:38