I have a Custom UIView, creating a line, which is rotating in around its own axis.
lineLayer = [[CAShapeLayer alloc] init];
UIBezierPath *bezierPath = [UIBezierPath bezierPath];
CGFloat width = CGRectGetWidth(self.frame)/2.0f;
CGFloat height = CGRectGetHeight(self.frame)/2.0f;
CGPoint centerPoint = CGPointMake(width, height);
CGPoint addLineToPoint = CGPointMake(width, -30);
[bezierPath moveToPoint:centerPoint];
[bezierPath addLineToPoint:addLineToPoint];
lineLayer.strokeColor = [UIColor whiteColor].CGColor;
lineLayer.frame = self.bounds;
lineLayer.lineWidth = 1.0;
lineLayer.path = bezierPath.CGPath;
[self.layer addSublayer:lineLayer];
[lineLayer setHidden:YES];
Now This View is set as PARENT CLASS of a UIView in Storyboard.
When I run Project, this linelayer is seen out of its parent View's Layer.
Here in this image, lineLayer is coming out of its parent UIView's and also another View is parent View in storyboard heirarchy.
Any help????
Replace this line
CGPoint addLineToPoint = CGPointMake(width, -30);
with
CGPoint addLineToPoint = CGPointMake(width, -height);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.