Reputation: 1098
It's hard for me to describe the problem, and I'll use screenshots. They are all from my simulator, when I test in my iPodTouch4
, its the same.
I have several UILabel
s, which are rects in the picture.
Notice there are black lines on the right of some rects, which is unexpected, because I didn't code any extra behavior except for backgoundColor and frame.
When I change UILabel
to UIView
(nothing else changed), every thing becomes normal!
And when use UILabel
not in retina display, we can see clearly than some rects have different width, but according to my code and the log, they have same width! Realllllly Weird!
I can't figure out why. It might be something special about UILabel
, but I can't find anywhere int the documentation.
[this is how I create labels]
NSMutableArray *labels = [NSMutableArray array];
for (NSString *day in [self getDaysOfTheWeek]) {
UILabel *dayOfWeekLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[labels addObject:dayOfWeekLabel];
}
self.dayOfWeekLabels = labels;
[this is where I set their frames]
int count = 0;
for (UILabel *dayLabel in self.dayOfWeekLabels) {
dayLabel.frame = CGRectMake(CELL_BORDER_WIDTH + count*(self.cellWidth+CELL_BORDER_WIDTH), CELL_BORDER_WIDTH, self.cellWidth, self.daysHeader.frame.size.height);
dayLabel.backgroundColor = self.dateBackgroundColor;
count++;
}
Just as I mentioned above, simply change these UILabel to UIView in these code make them looks differently.
Upvotes: 2
Views: 659
Reputation: 25144
Can you do a
dayLabel.autoresizingMask = 0;
dayLabel.frame = [...];
NSLog(@"frame: %@", NSStringFromCGRect(dayLabel.frame));
?
Check that you have only integer non-fractional dimensions (42.000 or 1337.000, not 42.500 or 1337.1234). This can be the source of your display problem.
Upvotes: 6
Reputation: 1179
If you are creating through xib then uncheck shadow enabled box, see whether it helps you out.
Upvotes: 0