iOS设置控件圆角,和label的行距。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS设置控件圆角,和label的行距。相关的知识,希望对你有一定的参考价值。
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的行距。的主要内容,如果未能解决你的问题,请参考以下文章