我做了一些研究,我看,有没有简单的方法,使只有右上和UIView的圆左上死角,对不对?
PS.这段代码使得所有4个角都是圆形的.我不想要.
#import <QuartzCore/QuartzCore.h>
self.layer.cornerRadius = 5;
self.layer.masksToBounds = YES;
Run Code Online (Sandbox Code Playgroud)
amb*_*amb 21
您可以使用此代码段执行此操作:
// Set top right & left corners
[self setMaskTo:yourView byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight];
Run Code Online (Sandbox Code Playgroud)
编辑
对不起,我忘了这个
- (void)setMaskTo:(UIView*)view byRoundingCorners:(UIRectCorner)corners
{
UIBezierPath *rounded = [UIBezierPath bezierPathWithRoundedRect:view.bounds
byRoundingCorners:corners
cornerRadii:CGSizeMake(8.0, 8.0)];
CAShapeLayer *shape = [[CAShapeLayer alloc] init];
[shape setPath:rounded.CGPath];
view.layer.mask = shape;
}
Run Code Online (Sandbox Code Playgroud)
PS:正如我在评论中所说,如果你在显示UITableViewCell单元格时使用这样的东西,我发现使用背景图像总是更好的选择,因为这种绘图材料总会影响性能.
| 归档时间: |
|
| 查看次数: |
1872 次 |
| 最近记录: |