iOS設置控件圓角,和label的行距。

1. 設置控件圓角spa

     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;
            

ci

2. 設置label行距it

NSString *text = @"wnklsaxknsalkxnaslxnaklxaslxamxlakxnaskxnaskxnankxnaskxnaslkx";table

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

 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;di

相關文章
相關標籤/搜索