不是 heightForRowAtIndexPath: 这个的间距,我指的是cell与cell之间的间距,默认是贴紧的!!!!
黄舟2017-04-17 17:30:45
你的意思是。 。就像微博裡面那樣。 。好像每個 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)
}
天蓬老师2017-04-17 17:30:45
可以設定多個section啊,每個section就一條cell,那麼cell之間的距離不就變成設定section之間的距離了。
section之間的距離不好設麼
天蓬老师2017-04-17 17:30:45
重寫cell的setFrame方法
MessageCellSectionMargin自訂一個數值
- (void)setFrame:(CGRect)frame {
CGRect cellFrame = frame;
cellFrame.size.height = cellFrame.size.height - MessageCellSectionMargin;
cellFrame.origin.y = cellFrame.origin.y + MessageCellSectionMargin;
frame = cellFrame;
[super setFrame:frame];
}