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

iOS设置控件圆角,和label的行距。

时间:2016-09-06 19:43:29      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

1. 设置控件圆角

     UIView *nameBgView = (UIView *)[PublicMethods creatViewWithType:@"UIView" andParent:name           andTag:kDrawCarTabelNameHeadBgViewTag];
            [nameBgView setFrame:CGRectMake(kDrawCarTableContentLabelXMargin, 30, name.frame.size.width-kDrawCarTableContentLabelXMargin*2, 50)];
            nameBgView.backgroundColor = [UIColor colorWithHex:0x43019d alpha:1];
            
            
            UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRoundedRect:nameBgView.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(5, 5)];
            
            CAShapeLayer *maskLayer = [CAShapeLayer layer];
            maskLayer.frame =nameBgView.bounds;
            maskLayer.path = bezierPath.CGPath;
            nameBgView.layer.mask = maskLayer;
            

2. 设置label行距

NSString *text = @"wnklsaxknsalkxnaslxnaklxaslxamxlakxnaskxnaskxnankxnaskxnaslkx";

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

 NSMutableAttributedString *attStrSupplier = [[NSMutableAttributedString alloc]initWithString:text];
            //创建NSMutableParagraphStyle实例
            NSMutableParagraphStyle *styleSupplier = [[NSMutableParagraphStyle alloc]init];
            //设置行距
            [styleSupplier setLineSpacing:10.0f];
       
            [attStrSupplier addAttribute:NSParagraphStyleAttributeName value:styleSupplier range:NSMakeRange(0,text.length)];
     
            contentLabel.attributedText =attStrSupplier;

 

iOS设置控件圆角,和label的行距。

标签:

原文地址:http://www.cnblogs.com/blogfan/p/5846815.html

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