Iphone 在视图中设置角点

Iphone 在视图中设置角点,iphone,quartz-2d,Iphone,Quartz 2d,我知道我可以用圆角作为 view.layer.cornerRadius = 10; 现在我想知道如何在选定的拐角处生成圆角?比如在左上角和右上角,而不是左下角和右下角。我该怎么做呢 提前感谢…两种方法: 1. use CALayer mask, mask out the corner you don't want. 或 像这样的东西只会画顶角- - (void)drawRect:(CGRect)rect { [super drawRect:rect]; UIBezierPath* roun

我知道我可以用圆角作为

view.layer.cornerRadius = 10;
现在我想知道如何在选定的拐角处生成圆角?比如在左上角和右上角,而不是左下角和右下角。我该怎么做呢

提前感谢…

两种方法:

1. use CALayer mask, mask out the corner you don't want.


像这样的东西只会画顶角-

- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];

UIBezierPath* roundedRectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(44.5, 12.5, 69, 46) byRoundingCorners: UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii: CGSizeMake(10, 10)];
[[UIColor whiteColor] setFill];
[roundedRectanglePath fill];

[[UIColor blackColor] setStroke];
roundedRectanglePath.lineWidth = 0.5;
[roundedRectanglePath stroke];

}

尽管不是完全相同,但我还是通过这些帖子找到了答案。非常感谢您的发现。UPE密切投票/链接有双重用途——它们可以防止重复,但也可以帮助提问者(以及使用您使用的术语进行搜索的其他人)找到他们在提问前可能没有遇到的答案。
- (void)drawRect:(CGRect)rect
{
[super drawRect:rect];

UIBezierPath* roundedRectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(44.5, 12.5, 69, 46) byRoundingCorners: UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii: CGSizeMake(10, 10)];
[[UIColor whiteColor] setFill];
[roundedRectanglePath fill];

[[UIColor blackColor] setStroke];
roundedRectanglePath.lineWidth = 0.5;
[roundedRectanglePath stroke];