Monday, November 28, 2011

iPhone | Convert UILabel to Circle

This is how you can convert a UILabel to circle:

1)Add Quartz Core framework to application frameworks

2) Import QuartzCore.h file to implementation file.

3) #define kRectArmLength 24.0 (Not necessary, as you can decide while initializing label with frame)

//Label will be a square (equal width & height)

UILabel *lblCircle = [[UILabel alloc] initWithFrame:CGRectMake(10,20, kRectArmLength, kRectArmLength)];

//set corner radius just half of the square arm length

lblCircle.layer.cornerRadius= kRectArmLength/2;


lblCircle.backgroundColor = [UIColor redColor];

[self.view adsSubview: lblCircle];

No comments:

Post a Comment