Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use rounded corner label in iphone, UILabel Round Corners

Tags:

ios

iphone

I am using some labels in a view. I want to make rounded corner label in my iphone application. I use following code to do this but it's not work. I got have some errors to use that properties.

label.layer.borderColor = [UIColor blueColor].CGColor;
label.layer.borderWidth = 4.0;
label.layer.cornerRadius = 8;
like image 409
M.B Avatar asked Dec 16 '11 05:12

M.B


2 Answers

This simple code enough for RoundLabel

LabelName.layer.cornerRadius = LableName.frame.size.height/2;
LabelName.layer.masksToBounds = YES;
like image 200
Ramdhas Avatar answered Nov 15 '22 21:11

Ramdhas


I was facing the same problem, using a UILabel with backgroundColor in a cell, and added this to work correctly :

label.layer.cornerRadius=8.0;
label.clipsToBounds=YES;
like image 44
Felipe FMMobile Avatar answered Nov 15 '22 22:11

Felipe FMMobile