在tableView是plain的狀態下,重寫該方法,可以實現cell之間,有間距,如圖效果
Snip20160719_8.png
//代碼入下
- (void)setFrame:(CGRect)frame{
frame.size.height -= 20;
frame.origin.y += 20;
[super setFrame:frame];
}
或者是在group 樣式下,有多少行就返回多少組,把第一組的cell,它的headerView的高度設置為0.01,這是蘋果的一個小bug,設置0.01相當于0,但是設置0又不起效果,只有這樣設,能滿足我們的需求了
代碼如下
#pragma mark - UITableViewDelegate
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section == 0) {
return 0.01;
}
return 5;
}