使用uiview ios

时间:2015-10-08 10:21:28

标签: ios objective-c uiview

我想创建带有bezier曲线的UIView,所以我正在实现以下代码,但我没有得到我想要的东西。

self.test = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height)];
self.test.backgroundColor = [UIColor greenColor];

[self.view addSubview:self.test];

UIBezierPath *myClippingPath = [UIBezierPath bezierPath];
[myClippingPath moveToPoint:CGPointMake(0, 150)];


[myClippingPath addCurveToPoint:CGPointMake([[UIScreen mainScreen]bounds].size.width, 100)
              controlPoint1:CGPointMake(0, 0)
              controlPoint2:CGPointMake([[UIScreen mainScreen]bounds].size.width, 100)];
[myClippingPath addCurveToPoint:CGPointMake(0, 225)
                 controlPoint1:CGPointMake(0, 100)
                  controlPoint2:CGPointMake([[UIScreen mainScreen]bounds].size.width, 225)];




CAShapeLayer *mask = [CAShapeLayer layer];
mask.path = myClippingPath.CGPath;

self.test.layer.mask = mask;

这里我得到了以下输出,但我希望在底部和底部都有相同的曲线,就像我在底部一样。 output

Needed output

0 个答案:

没有答案