【发布时间】:2014-06-30 11:15:46
【问题描述】:
我需要在 iOS 7 中显示与 iOS 6 相同的分隔线(如图 2 所示)。我在 CellForRowAtIndexPath 中使用以下代码:
UIView* separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];
separatorLineView.backgroundColor = [UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1.0];
[cell.contentView addSubview:separatorLineView];
UIView *customColorView = [[UIView alloc] init];
customColorView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_highlighted.png"]];
cell.selectedBackgroundView = customColorView;
cell.backgroundColor=[UIColor clearColor];
//Separation style for iOS7
if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[tableView setSeparatorInset:UIEdgeInsetsZero];
}
return cell;
我得到如下图的输出:
但是对于 IOS 6 和 7,我的输出应该如下图所示:
谁能帮助我如何实现这一目标?谢谢..
【问题讨论】:
标签: iphone uitableview ios7