0
设置角落我知道我可以做的UIView与圆角作为在查看
view.layer.cornerRadius = 10;
现在我想知道我怎样才能使所选择的角落圆角?就像在左上角和右上角,而不是在左下角和右下角。我怎么能做到这些?
在此先感谢...
设置角落我知道我可以做的UIView与圆角作为在查看
view.layer.cornerRadius = 10;
现在我想知道我怎样才能使所选择的角落圆角?就像在左上角和右上角,而不是在左下角和右下角。我怎么能做到这些?
在此先感谢...
像这样的事情会借鉴,只有顶部边角 -
- (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];
}
两种方法:
1. use CALayer mask, mask out the corner you don't want.
或
2. use Core Graphic, create a clip path.
即使不完全重复,我通过这些帖子找到了答案。非常感谢您的调查结果 – rakeshNS 2012-03-20 17:12:37
Dupe关闭投票/链接是双重目的 - 它们可以防止重复,但它们也可以帮助提问者(以及任何使用您使用的术语进行搜索的人)找到他们可能没有的答案在提出问题之前遇到。 – jrturton 2012-03-20 17:34:34