uitableview - iOS 中 tableView 怎么设置Cell与Cell 之间的间距?
高洛峰
高洛峰 2017-04-17 17:28:45

不是 heightForRowAtIndexPath: 这个的间距,我指的是cell与cell之间的间距,默认是贴紧的!!!!

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(7)
黄舟

你的意思是。。就像微博里面那样。。好像每个 cell 之间有间隙那种么?

笨方法,每个cell 里面设置一点点空白区域啊 X D

override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {

    return 60.0f
}

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

    cell.contentView.backgroundColor = UIColor.clearColor()

    let gapView : UIView = UIView(frame: CGRectMake(0, 10, self.view.frame.size.width, 120))

    gapView.layer.backgroundColor = UIColor(red: 1.0f, green: 1.0f, blue: 1.0f, alpha: 1.0f)
    gapView.layer.masksToBounds = false
    gapView.layer.cornerRadius = 2.0f
    gapView.layer.shadowOffset = CGSizeMake(-1, 1)
    gapView.layer.shadowOpacity = 0.2f

    cell.contentView.addSubview(gapView)
    cell.contentView.sendSubviewToBack(gapView)
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!