为cell设计(画)圆角

2018-11-07  本文已影响1人  乐乐的熊

https://www.jianshu.com/p/2df0ea05c005

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    CGFloat cellWidth =cell.width;
    CGFloat cellHeight = cell.height;
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.frame = CGRectMake(0, 0, cellWidth, cellHeight);
    
    CGFloat cornerRadius =5;
    UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, cellWidth, cellHeight) cornerRadius:cornerRadius];
    maskLayer.path = bezierPath.CGPath;
    [cell.layer setMask:maskLayer];
    
}
上一篇 下一篇

猜你喜欢

热点阅读