如何删除iOS 7中的分隔线? [英] How to remove separator line in iOS 7?
本文介绍了如何删除iOS 7中的分隔线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
第一个截图是iOS7,不是我想要的。
第一个截图是iOS6我想要的。
First screenshot is iOS7 that not what I want.
First screenshot is iOS6 that what I want.
Tableview的风格很简单。< br>
Tableview的分隔符是none。
Tableview's style is plain.
Tableview's separator is none.
并且有一个深灰色的backgroudView。
And there is a backgroudView of that darkgray color.
我的代码如下所示
if ([tableView respondsToSelector:@selector(setSeparatorInset:)])
{
[tableView setSeparatorInset:UIEdgeInsetsZero];
}
cell.backgroundView = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"icon_bg_box.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ];
推荐答案
你需要添加单独的视图作为分隔符
首先使tableViews分隔符为无
You need to add separate view as a seperator First make tableViews seperator to none
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
[cell addSubview:[self drawSeparationView:(indexPath.row)]];
return cell;
}
然后绘制你的分隔符
- (UIView*)drawSeparationView:(NSInteger)itemNo {
UIView *view = [[UIView alloc] init];
view.frame = CGRectMake(0, 0, self.tableView.frame.size.width, cellHeight);
UIView *upperStrip = [[UIView alloc]init];
upperStrip.backgroundColor = [UIColor colorWithWhite:0.138 alpha:1.000];
upperStrip.frame = CGRectMake(0, 0, view.frame.size.width, 2);
[view addSubview:upperStrip];
UIView *lowerStrip = [[UIView alloc]init];
lowerStrip.backgroundColor = [UIColor colorWithWhite:0.063 alpha:1.000];
lowerStrip.frame = CGRectMake(0, cellHeight-2, view.frame.size.width, 2);
[view addSubview:lowerStrip];
return view;
}
输出将是这样的
这篇关于如何删除iOS 7中的分隔线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文