label.layer.borderColor = .... not working (Xcode 4.3.2)

ios, iphone, uilabel, xcode

Solution

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).

Problem

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.

Original source

Related problems