码迷,mamicode.com
首页 > 移动开发 > 详细

自定义切圆角 IOS

时间:2015-05-23 10:07:48      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:uibezierpath   cashapelayer   

NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:@"进击的巨人"];

    NSShadow *shadow = [[NSShadow alloc]init];

    shadow.shadowColor = [UIColor darkGrayColor];

    shadow.shadowBlurRadius = 1;

    [attString setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:shadow,NSShadowAttributeName, nil] range:NSMakeRange(0, attString.length)];

    UILabel *l = [[UILabel alloc]init];

    l.frame = CGRectMake(240, 160, 100, 30);

    l.backgroundColor = [UIColor clearColor];

    l.attributedText = attString;

    [self addSubview:l];





-(void)createUI{

    

    

    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:_codeBtn.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomLeft cornerRadii:CGSizeMake(5, 5)];

    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];

    maskLayer.frame = _codeBtn.bounds;

    maskLayer.path = maskPath.CGPath;

    _codeBtn.layer.mask = maskLayer;

    

    

    UIBezierPath *maskPath1 = [UIBezierPath bezierPathWithRoundedRect:_coutryBtn.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerBottomRight cornerRadii:CGSizeMake(5, 5)];

    CAShapeLayer *maskLayer1 = [[CAShapeLayer alloc] init];

    maskLayer1.frame = _coutryBtn.bounds;

    maskLayer1.path = maskPath1.CGPath;

    _coutryBtn.layer.mask = maskLayer1;

    

    

    UIBezierPath *maskPath2 = [UIBezierPath bezierPathWithRoundedRect:_phoneNo.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomLeft cornerRadii:CGSizeMake(5, 5)];

    CAShapeLayer *maskLayer2 = [[CAShapeLayer alloc] init];

    maskLayer2.frame = _phoneNo.bounds;

    maskLayer2.path = maskPath2.CGPath;

    _phoneNo.layer.mask = maskLayer2;

    

    

    UIBezierPath *maskPath3 = [UIBezierPath bezierPathWithRoundedRect:_sendBtn.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerBottomRight cornerRadii:CGSizeMake(5, 5)];

    CAShapeLayer *maskLayer3 = [[CAShapeLayer alloc] init];

    maskLayer3.frame = _sendBtn.bounds;

    maskLayer3.path = maskPath3.CGPath;

    _sendBtn.layer.mask = maskLayer3;

    

    

//    _testLabel.layer.masksToBounds = YES;

//    _testLabel.layer.cornerRadius = 5;

//    

//    _sumbitLabel.layer.masksToBounds = YES;

//    _sumbitLabel.layer.cornerRadius = 5;

}

自定义切圆角 IOS

标签:uibezierpath   cashapelayer   

原文地址:http://blog.csdn.net/chungeshihuatian/article/details/45932171

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!