Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set label border in iphone

How can I set label's border which is dynamically generated (Not from Interface Builder)?

like image 610
iOS_User Avatar asked Mar 31 '10 09:03

iOS_User


2 Answers

you can do it by

Label.layer.borderColor = [UIColor whiteColor].CGColor;
Label.layer.borderWidth = 4.0;

before this you need to import a framework QuartzCore/QuartzCore.h

like image 116
Mihir Mehta Avatar answered Nov 14 '22 21:11

Mihir Mehta


Swift version

enter image description here

Set label border

label.layer.borderWidth = 2.0

Set border color

label.layer.borderColor = UIColor.blueColor().CGColor

Use rounded corners

label.layer.cornerRadius = 8

Make background color stay within rounded corners

label.layer.masksToBounds = true
like image 3
Suragch Avatar answered Nov 14 '22 20:11

Suragch