I'm new to xcode and want to add black outline to UIButton that is 1px wide. I have searched through the inspector for UIButton in Xcode but couldn't find the setting. I have read through the documentation on UIButton but it doesn't seem to have this particular function. Is it possible to add colored outlines to UIButton?
Asked
Active
Viewed 1,415 times
2
-
2maybe `btn.layer.borderColor` and `btn.layer.borderWidth` is what you want – Wilson XJ Jul 12 '16 at 02:13
-
can this be done to UIButton I have added via storyboard? – Thor Jul 12 '16 at 02:15
-
1check this: http://stackoverflow.com/questions/12301256/is-it-possible-to-set-uiview-border-properties-from-interface-builder/17993890#17993890 – Wilson XJ Jul 12 '16 at 02:27
-
Pro-tips for posting: you're posting a lot of questions, and it seems to me that you may learn more if you spend less time asking questions and more time finding out answers, e.g. using a search engine. It is very easy to ask a question, but if one does it too frequently, it offloads the necessary effort onto volunteers. We very much encourage posters to self-learn in the first instance, and then ask if they are _genuinely_ stuck. – halfer Dec 14 '16 at 23:14
-
We also like care being taken over questions. They don't have to be Shakespeare, but upper case letters at the start of sentences, question marks at the end of questions, as well as detail and research, are all appreciated. Keep them succinct too, boilerplate like `I have tried to solve this problem for
, could someone please help me out? Thanks in advance for any help` is better omitted, since it does not add anything to the question. Ask a clear question instead. – halfer Dec 14 '16 at 23:16
2 Answers
5
In viewDidLoad() I put:
self.buttonName.layer.borderWidth = 1
self.buttonName.layer.borderColor = UIColor.whiteColor().CGColor

Wayne Filkins
- 317
- 1
- 5
- 14
4
You can add an outline to a view by accessing its layer and modifying the
borderWidth
and borderColor

MirekE
- 11,515
- 5
- 35
- 28