【发布时间】:2010-06-09 20:21:18
【问题描述】:
我有一个 UILabel,我使用cornerRadius 在图层上创建了一个半径。最终目标是让标签看起来像 Apple 在邮件应用程序中所做的那样。
一开始看起来不错,但是一旦您深入该行并返回几次,圆边的质量就会开始下降。您可以在屏幕截图中看到,左侧是块状的。
为什么会发生这种情况?它似乎在加载该视图大约 2 次后发生。
(来源:puc.edu)
这是我的单元格创建方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
Trip *trip = [fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = trip.title;
cell.detailTextLabel.text = @"Date of trip";
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// Create a nice number, like mail uses
UILabel *count = [[UILabel alloc] initWithFrame:CGRectMake(cell.contentView.frame.size.width - 50, 12, 34, 20)];
[count setText:[NSString stringWithFormat:@"%i",[[trip.rides allObjects] count]]];
[count setFont:[UIFont fontWithName:@"Helvetica-Bold" size:16]];
count.textAlignment = UITextAlignmentCenter;
count.backgroundColor = [UIColor grayColor];
count.textColor = [UIColor whiteColor];
count.layer.cornerRadius = 10;
[cell addSubview:count];
[count release];
return cell;
}
【问题讨论】:
-
你能发布更多你的细胞创建方法吗?
-
没问题,我已经更新了代码。
标签: iphone uitableview uilabel