Is there a way for UILabel to draw a border around itself? This is useful for me to debug the text placement and to see the placement and how big the label actually is.
+6
A:
You can set label's border via its underlying CALayer property:
myLabel.layer.borderColor = [UIColor greenColor].CGColor;
myLabel.layer.borderWidth = 3.0;
Vladimir
2010-02-22 14:59:10
Compiler complaints that there is no definition of borderColor and borderWidth within CALayer.
Boon
2010-02-22 15:15:07
they're available only starting SDK 3.0 :( If you want just a quick solution for debugging purpose you can set semitransparent colored background for your label.
Vladimir
2010-02-22 15:22:04
If the compiler complains then you probably forgot to `#import <QuartzCore/QuartzCore.h>`
St3fan
2010-02-22 15:37:58
@Vladmir: you saved my life. Thanks!!!!!
Digital Robot
2010-03-28 19:19:48