您好,欢迎来电子发烧友网! ,新用户?[免费注册]

您的位置:电子发烧友网>源码下载>通讯/手机编程>

UITableView开发需要注意的细节

大小:0.3 MB 人气: 2017-09-26 需要积分:2

  # 1.隐藏分割线

  # 2.隐藏多余Cell

  //##?在ViewController初始化时候加载 如viewDidLoad

  //隐藏分割线

  tableView.separatorStyle = UITableViewCellSeparatorStyle.None

  //隐藏多余的cell

  tableView.tableFooterView = UIView(frame: CGRectZero)

  # 3.分割线头部顶到底、分割线颜色

  ///##?分割线头部顶到底、分割线颜色

  //启动、旋转、视图大小位置发生改变、增加子视图等。。都会调用

  override func viewDidLayoutSubviews() {

  tableView.separatorInset = UIEdgeInsetsZero

  tableView.layoutMargins = UIEdgeInsetsZero

  //articleTableView.separatorColor = UIColor.redColor() //分割线颜色

  }

  //没当cell即将出现屏幕时候都会调用此方法

  func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {

  cell.separatorInset = UIEdgeInsetsZero

  cell.layoutMargins = UIEdgeInsetsZero

  }

  # 4.自定义点击后效果 Cell 背景等更改

  //##?在cellForRowAtIndexPath方法使用

  //点击Cell时,没有点击效果

  cell.selectionStyle = UITableViewCellSelectionStyle.None

  //系统默认的颜色 .Blue蓝色-默认 .Grap灰色 .None 无色

  //点击Cell时,自定义选中后的背景视图

  //背景颜色

  cell.selectedBackgroundView = UIView()

  cell.selectedBackgroundView?.backgroundColor = UIColor.clearColor()

非常好我支持^.^

(0) 0%

不好我反对

(0) 0%

      发表评论

      用户评论
      评价:好评中评差评

      发表评论,获取积分! 请遵守相关规定!