I've just added a UILabel componet into a view and I'm trying to make it a rounded corner UILabel. I’ve been reading some questions and answers related to the same issue but all of them says that I have to change the source code. Is it really necessary in the new Xcode 4.5 and iOS6? Also I’m not sure if I’m able to see the code generated by the mainstoryboard.
Any help will be appreciated.
Many thanks, Marcos
masksToBounds = true" is an important code, if you apply corner radius to a label and if it dosen't work than adding this will definitely add the corner radius to a particular label.. So this should be the correct answer..
The corner radius is a measurement describing the curve on the corners of your labels. This is measured in millimetres and refers to the radius of the circle created if the curve was extended to create a full circle.
You can do it all in Interface Builder.
In XCode, select your .xib
file (or your storyboard) to open Interface Builder. Click on your UILabel
and open the Identity inspector (if you do not know where it is, go to XCode's Help menu and type in "Identity inspector"). Click the plus button under the User Defined Runtime Attributes pane, and write layer.cornerRadius
for the Key Path, chose Number
for the Type, and 5
(or any other number) for the Value.
If you run now your project you should get a round-cornered UILabel
.
to make UILabel with rounded corners do the following:
#import <QuartzCore/QuartzCore.h>
then you should refer to your UILabel
yourLabel.layer.cornerRadius = 5;
5 is just an example, of course
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With