不是 heightForRowAtIndexPath: 这个的间距,我指的是cell与cell之间的间距,默认是贴紧的!!!!
黄舟2017-04-17 17:30:45
You mean. . Just like in Weibo. . Does it seem like there are gaps between each cell?
Stupid method, set a little blank area in each 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
The height of each cell is a little higher (higher than the spacing you want), the cell background is set to transparent, use your own view as the background, do not fill the cell, and leave the height you exceed
天蓬老师2017-04-17 17:30:45
It would be better if you use heightForRowAtIndexPath:
to leave a little more height...
天蓬老师2017-04-17 17:30:45
You can set multiple sections. Each section has one cell, so the distance between cells becomes the distance between sections.
Is it difficult to set the distance between sections?
黄舟2017-04-17 17:30:45
The method on the first floor is the most reliable. The performance of collectionView is relatively poor. It is more cost-effective to set more blanks in the cell.
天蓬老师2017-04-17 17:30:45
Rewrite the setFrame method of cell
MessageCellSectionMargin customizes a value
- (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];
}