UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_baseView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(5, 5)];CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];//设置大小maskLayer.frame = _baseView.bounds;//设置图形样子maskLayer.path = maskPath.CGPath;_baseView.layer.mask = maskLayer;
注意:如果在tableVIewCell的- (void)awakeFromNib {}方法中是要给frame,因为这个方法只加载xib原本的尺寸,导致布局会有问题