iOS开发小技巧

 UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
//    lab.layer.borderColor = [UIColor blueColor].CGColor;
//    lab.layer.borderWidth = 1;
//    lab.clipsToBounds = YES;
//    lab.layer.cornerRadius= 5;
    lab.backgroundColor = [UIColor blueColor];
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:lab.bounds byRoundingCorners:UIRectCornerTopLeft cornerRadii:CGSizeMake(19,19)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
    maskLayer.frame = lab.bounds;
    maskLayer.path = maskPath.CGPath;
    lab.layer.mask = maskLayer;
    [self.view addSubview:lab];

posted on 2016-06-08 11:05  WW稳  阅读(94)  评论(0)    收藏  举报