当前位置:首页 > 操作系统 > Ios

自定义切圆角 IOS

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

    NSShadow *shadow = [[NSShadowalloc]init];

    shadow.shadowColor = [UIColordarkGrayColor];

    shadow.shadowBlurRadius = 1;

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

    UILabel *l = [[UILabelalloc]init];

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

    l.backgroundColor = [UIColorclearColor];

    l.attributedText = attString;

    [selfaddSubview:l];





-(void)createUI{

    

    

    UIBezierPath *maskPath = [ UIBezierPath bezierPathWithRoundedRect:_codeBtn.boundsbyRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomLeftcornerRadii:CGSizeMake(5, 5)];

    CAShapeLayer *maskLayer = [[CAShapeLayeralloc] init];

    maskLayer.frame = _codeBtn.bounds;

    maskLayer.path = maskPath.CGPath;

    _codeBtn.layer.mask = maskLayer;

    

    

    UIBezierPath *maskPath1 = [ UIBezierPath bezierPathWithRoundedRect:_coutryBtn.boundsbyRoundingCorners:UIRectCornerTopRight | UIRectCornerBottomRightcornerRadii:CGSizeMake(5, 5)];

    CAShapeLayer *maskLayer1 = [[CAShapeLayeralloc] init];

    maskLayer1.frame = _coutryBtn.bounds;

    maskLayer1.path = maskPath1.CGPath;

    _coutryBtn.layer.mask = maskLayer1;

    

    

    UIBezierPath *maskPath2 = [ UIBezierPath bezierPathWithRoundedRect:_phoneNo.boundsbyRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomLeftcornerRadii:CGSizeMake(5, 5)];

    CAShapeLayer *maskLayer2 = [[CAShapeLayeralloc] init];

    maskLayer2.frame = _phoneNo.bounds;

    maskLayer2.path = maskPath2.CGPath;

    _phoneNo.layer.mask = maskLayer2;

    

    

    UIBezierPath *maskPath3 = [ UIBezierPath bezierPathWithRoundedRect:_sendBtn.boundsbyRoundingCorners:UIRectCornerTopRight | UIRectCornerBottomRightcornerRadii:CGSizeMake(5, 5)];

    CAShapeLayer *maskLayer3 = [[CAShapeLayeralloc] 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;

}

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


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!