项目需要画个曲线如何做呢?

UIView *viw = [[UIView alloc] initWithFrame:CGRectMake(50, 100, SELF_WIDTH - 100, SELF_WIDTH)];

viw.backgroundColor = [UIColor orangeColor];

[self.view addSubview:viw];

UIView *myCustomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,viw.width, 120)];

myCustomView.backgroundColor = [UIColor whiteColor];

[viw addSubview:myCustomView];

UIBezierPath *bezierPath = [UIBezierPath bezierPath];

[bezierPath moveToPoint:CGPointMake(0, 0)];

[bezierPath addCurveToPoint:CGPointMake(myCustomView.width, 0) controlPoint1:CGPointMake(0, 0) controlPoint2:CGPointMake(myCustomView.width/2, 100)];

[bezierPath addLineToPoint:CGPointMake(myCustomView.width, myCustomView.height)];

[bezierPath addLineToPoint:CGPointMake(0, myCustomView.height)];

[bezierPath closePath];

CAShapeLayer *shapLayer = [CAShapeLayer layer];

shapLayer.path = bezierPath.CGPath;

myCustomView.layer.mask = shapLayer;

myCustomView.layer.masksToBounds = YES;


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容