-
先上效果圖

1.png
-
實(shí)現(xiàn)方式
只需要在自定義cell上加上一個(gè)view,然后把view設(shè)置邊框陰影
+ (instancetype)cellWithTableView:(UITableView *)tableView{
static NSString *ID = @"cell";
XTTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
if (!cell) {
cell = [[XTTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
CGFloat W = [UIScreen mainScreen].bounds.size.width;
//創(chuàng)建一個(gè)UIView比cell.contentView小一圈
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10, 5, W - 20, 90)];
view.backgroundColor = [UIColor whiteColor];
//給view邊框設(shè)置陰影
view.layer.shadowOffset = CGSizeMake(1,1);
view.layer.shadowOpacity = 0.3;
view.layer.shadowColor = [UIColor blackColor].CGColor;
[cell.contentView addSubview:view];
}
return cell;
}