【发布时间】:2015-12-19 17:24:23
【问题描述】:
我有一个带有布局约束(宽度:400,高度:180)的 UIView,我想在视图中添加一个贝塞尔曲线。
我的贝塞尔曲线是这样的:
UIBezierPath* bezierPath = [UIBezierPath bezierPath];
// origin, height | left border
[bezierPath moveToPoint: CGPointMake(0, 20)];
// origin, height | left border
[bezierPath addLineToPoint: CGPointMake(0, _donationView.frame.size.height)];
// height, width | bottom border
[bezierPath addLineToPoint: CGPointMake(_donationView.frame.size.width , _donationView.frame.size.height)];
[bezierPath addLineToPoint: CGPointMake(_donationView.frame.size.width, 20)];
[bezierPath addLineToPoint: CGPointMake(_donationView.frame.size.width - 20, 20)];
[bezierPath addLineToPoint: CGPointMake(_donationView.frame.size.width - 30, 15)];
[bezierPath addLineToPoint: CGPointMake(_donationView.frame.size.width - 40, 20)];
[bezierPath addLineToPoint: CGPointMake(0, 20)];
[bezierPath closePath];
[UIColor.grayColor setFill];
[bezierPath fill];
[UIColor.blackColor setStroke];
bezierPath.lineWidth = 1;
[bezierPath stroke];
创建贝塞尔曲线后,我传递给:
CAShapeLayer *shapeView = [[CAShapeLayer alloc] initWithLayer:_donationView.layer];
[shapeView setPath:bezierPath.CGPath];
_donationView.layer.mask = shapeView;
但是贝塞尔曲线转到这个 CGRect(0, 0, 240, 128);
我怎样才能获得 (0,0,400, 180) 的 CGRect?
谢谢大家
【问题讨论】:
标签: ios objective-c uiview uibezierpath