设置一个uiview的部分圆角

有时候我们需要下面这种效果,并不能设置全部的圆角

直接上代码:

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_stateBGImgView.bounds
                                                       byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerBottomLeft)
                                                             cornerRadii:CGSizeMake(27, 27)];
        
        CAShapeLayer *maskLayer = [CAShapeLayer layer];
        
        maskLayer.frame = _stateBGImgView.bounds;
        maskLayer.path = maskPath.CGPath;
        
        _stateBGImgView.layer.mask = maskLayer;

希望写代码开心!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s