UITableView的style的区别与用法,以及分割线的显示与隐藏

来源:互联网 发布:ubuntu查找已安装软件 编辑:程序博客网 时间:2024/06/05 11:56

cell.selectionStyle = UITableViewCellSelectionStyleNone;//让cell不能选中

  //从新设置cell的背景,可以让cell分割线消失

  UIView *tempView = [[UIViewalloc] init];

  tempView.backgroundColor=[UIColorwhiteColor];

  [cell setBackgroundView:tempView];


  //也可以让分割线消失

  _saleTableView.separatorStyle =UITableViewCellSeparatorStyleNone;


  在viewcell里面自定义分割线

  //在每行加分割线

  - (void)drawRect:(CGRect)rect

  {

      CGFloat gap = (ScreenWidth > 350 ) ? 15 : 10;

    

      CGContextRef context = UIGraphicsGetCurrentContext();

      CGContextSetStrokeColorWithColor(context, [UIColor lightGrayColor].CGColor);

      CGContextStrokeRect(context, CGRectMake(gap, rect.size.height , rect.size.width - gap * 2, 1));

  }


  //tableview style不同的区别

  style=UITableViewStyleGrouped  默认会有headview和footview,头尾会空出一些距离,headview和footview会随tableview一起滑动,

  style=UITableViewStylePlain 默认没有headview和footview,自定义的headview和footview不会随tableview一起滑动,


  _saleTableView = [[UITableViewalloc] initWithFrame:CGRectMake(0,0, FRAMEW(self.view), FRAMEH(self.view) -56  - 64)styleUITableViewStyleGrouped];


  _saleTableView = [[UITableViewalloc] initWithFrame:CGRectMake(0,0, FRAMEW(self.view), FRAMEH(self.view) -56  - 64)styleUITableViewStylePlain];




0 0
原创粉丝点击