I need to draw a rounded rectangle bar in my iOS application, but without using a background image. Is there any way to make a rounded rectangle view or label?
9
votes
4 Answers
30
votes
5
votes
Alternative if you're using the UI designer (Storyboard or nib file) you can set a User Defined Runtime Attribute.
Click on the view you want to have rounded corners, click Show the Identity Inspector (3rd tab, top right). Then click the + in User Defined Runtime Attributes and enter the following:
Key Path: layer.cornerRadius
Type: Number
Value: whatever number, e.g. 5
4
votes
2
votes
It may be useful for you. Step1 :add the quartzcore framework to your project frameworks. In which file you want to write this code there, you have to use this.
#import <QuartzCore/QuartzCore.h>
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 100, 50, 30)];
myLabel.text = @"text";
myLabel.layer.cornerRadius =8.0;
[self.view addSubview:myLabel];