简体   繁体   中英

Bezierpath with rounded corners

I am using the following code to show the pointer like triangle view as shown in image below.

 UIView *triangleView = [[UIView alloc] initWithFrame:CGRectMake(70.0f,58.0f, self->_createAccountView.frame.size.width ,20.0f)];
    UIBezierPath* trianglePath = [UIBezierPath bezierPath];
    [trianglePath moveToPoint:CGPointMake(0, 0)];
    [trianglePath addLineToPoint:CGPointMake((self->_createAccountView.frame.size.width/7) -8, (self->_createAccountView.frame.size.height/4))];
    [trianglePath addLineToPoint:CGPointMake((self->_createAccountView.frame.size.width/5) , 0)];
    [trianglePath closePath];
    trianglePath.lineJoinStyle = kCGLineJoinRound;

    CAShapeLayer *triangleMaskLayer = [CAShapeLayer layer];
    [triangleMaskLayer setPath:trianglePath.CGPath];
    triangleView.backgroundColor = [UIColor colorWithRed:1.00 green:1.00 blue:1.00 alpha:1.0];

    triangleView.layer.mask = triangleMaskLayer;
    [self->_AccountView addSubview:triangleView];

This works fine but I want the pointing edge of the triangle view to be rounded. How can make it rounded? Any help is appreciated!

在此处输入图片说明

Change the lineJoin to kCALineJoinRound .

triangleMaskLayer.lineJoin = kCALineJoinRound;

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM