I am working in a class that is a subclass of UITableViewCell and have firstLabel and secondLabel properties declared in .h and being @synthesize in .m. When I go to format the UILabels programmatically, I try to set the border around the firstLabel. From the answer given in this question, I tried to do the same in my project.
firstLabel.layer.borderColor = [UIColor blackColor].CGColor;
The problem is that it won't recognize it, after I type firstLabel.layer. and hit 'esc' (to get the list of completions) Xcode comes up with nothing. What is the problem?
Note: if I type
firstLabel.textAlignment = UITextAlignmentCenter;
it works just fine and behaves as expected.
You need to import the QuartzCore header. #import <QuartzCore/QuartzCore.h>
(And don't forget to add the QuartzCore library as well or you will get a linker error when you try to build).
Did you set border width?
Like this:
[firstLabel.layer setBorderWidth:1.0f];
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