2

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.

1.Retina display, UILabels

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! Retina display, UIViews

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! no retina display UILabel

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.

4

2 に答える 2

6

できますか

dayLabel.autoresizingMask = 0;
dayLabel.frame = [...];
NSLog(@"frame: %@", NSStringFromCGRect(dayLabel.frame));

?

分数以外の整数次元のみを使用していることを確認します(42.500 または 1337.1234 ではなく、42.000 または 1337.000)。これが表示の問題の原因である可能性があります。

于 2012-09-17T07:25:41.050 に答える
0

xib を使用して作成している場合は、シャドウを有効にするボックスのチェックを外して、役立つかどうかを確認してください。

于 2012-09-17T06:21:51.910 に答える