UIView *testview = [[UIView alloc] init]; testview.layer.cornerRadius = 10; [self.view addSubview: testview];
UIView *testview = [[UIView alloc] init]; [self.view addSubview: testview]; UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect: testview.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10,10)]; //创建 layer CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; maskLayer.frame = testview.bounds; //赋值 maskLayer.path = maskPath.CGPath; testview.layer.mask = maskLayer;
原文:https://www.cnblogs.com/-yun/p/12133495.html