iOS开发之指定UIView的某几个角为圆角
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(120, 10, 80, 80)];
view2.backgroundColor = [UIColor redColor];
[self.view addSubview:view2];
?? ?
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = view2.bounds;
maskLayer.path = maskPath.CGPath;
view2.layer.mask = maskLayer;
其中,
byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
指定了需要成為圓角的角。該參數(shù)是UIRectCorner類型的,可選的值有:
* UIRectCornerTopLeft
* UIRectCornerTopRight
* UIRectCornerBottomLeft
* UIRectCornerBottomRight
* UIRectCornerAllCorners
參考鏈接http://stackoverflow.com/questions/2264083/rounded-uiview-using-calayers-only-some-corners-how
轉(zhuǎn)載于:https://my.oschina.net/u/868062/blog/465778
總結(jié)
以上是生活随笔為你收集整理的iOS开发之指定UIView的某几个角为圆角的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Linux内存 性能调优
- 下一篇: Kuskal/Prim POJ 1789