利用UIBezierPath给控件各个边角加上圆角



    self.topView = [UIView new];

    [self.view addSubview:self.topView];

    self.topView.sd_layout

    .leftSpaceToView(self.view, (CKScreenW -300)/2)

    .topSpaceToView(self.view,CKScreenH/2 - 160)

    .widthIs(300)

    .heightIs(15);

    self.topView.backgroundColor = [UIColor whiteColor];

    

//    typedef NS_OPTIONS(NSUInteger, UIRectCorner) {

//        UIRectCornerTopLeft     = 1 << 0,

//        UIRectCornerTopRight    = 1 << 1,

//        UIRectCornerBottomLeft  = 1 << 2,

//        UIRectCornerBottomRight = 1 << 3,

//        UIRectCornerAllCorners  = ~0UL

//    };

 



    UIBezierPath *maskPath2 = [UIBezierPathbezierPathWithRoundedRect:self.topView.boundsbyRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRightcornerRadii:CGSizeMake(1010)];



 CAShapeLayer *maskLayer2 = [[CAShapeLayer allocinit];

 maskLayer2.frame = self.topView.bounds;

    maskLayer2.path = maskPath2.CGPath;

    self.topView.layer.mask = maskLayer2;




猜你喜欢

转载自blog.csdn.net/dangbai01_/article/details/80249224