在向一些 UILabel 添加字体和阴影后,我注意到当视图从堆栈中弹出时表视图动画滞后(像 FB/Path 使用的侧面滑动)。在我添加 UILabel 阴影之前,侧面滑动是平滑的。
我想我可能将它添加到错误的位置,因此标签属性可能被错误地添加。请看下面的cellForRowAtIndexPath:
方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString * cellReuseIdentifier = @"cellReuseIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellReuseIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellReuseIdentifier];
}
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 2, self.view.bounds.size.width, 200)];
imageView.image = [UIImage imageNamed:@"rest.jpg"];
[cell.contentView addSubview:imageView];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 2, 320, 30)];
titleLabel.text = (NSString *)[[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"title"];
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.textColor = [UIColor whiteColor];
[titleLabel setFont:[UIFont fontWithName:@"HelveticaNeue" size:24]];
titleLabel.layer.shadowColor = [[UIColor whiteColor] CGColor];
titleLabel.layer.shadowOpacity = 0.7;
[cell.contentView addSubview:titleLabel];
UILabel *detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 160, cell.bounds.size.width, 30)];
detailLabel.text = (NSString *)[[publicDataArray objectAtIndex:indexPath.row] objectForKey:@"description"];
detailLabel.backgroundColor = [UIColor clearColor];
detailLabel.textColor = [UIColor whiteColor];
[detailLabel setFont:[UIFont fontWithName:@"HelveticaNeue" size:18]];
detailLabel.layer.shadowColor = [[UIColor whiteColor] CGColor];
detailLabel.layer.shadowOpacity = 0.7;
[cell.contentView addSubview:detailLabel];
cell.contentView.backgroundColor = [UIColor clearColor];
return cell;
}
谢谢你的帮助。