6

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.

Community
  • 1
  • 1
tarheel
  • 4,727
  • 9
  • 39
  • 52

2 Answers2

8

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

borrrden
  • 33,256
  • 8
  • 74
  • 109
  • Worked like a charm. Sadly now my UITableView is rendering quite slowly, got any suggestions there? – tarheel Jun 11 '12 at 03:30
  • Pretty vague, it would warrant an entirely new question with info about your code that makes your cells. A blanket statement, though, is *do less work in cellForRowAtIndex* – borrrden Jun 11 '12 at 03:31
  • Thanks for the tip. Will try to work on my own first, then possibly submit a question later on. – tarheel Jun 11 '12 at 03:35
5

Did you set border width?

Like this:

[firstLabel.layer setBorderWidth:1.0f];
Dzy
  • 153
  • 4