资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

iOSUILabel设置行高

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

10年积累的网站设计制作、成都网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有轵城免费网站建设让你可以放心的选择与我们合作。

    tileLabel.numberOfLines = 0;

    tileLabel.backgroundColor = [UIColor clearColor];

    tileLabel.text = @"调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头调整行间距云头";

    tileLabel.font = [UIFont systemFontOfSize:11.0f];

    tileLabel.textColor = [Tools colorWithHex:0x787878];


    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:tileLabel.text];

    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];

    [paragraphStyle setLineSpacing:18];//调整行间距

    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [tileLabel.text length])];

    tileLabel.attributedText = attributedString;


    NSDictionary *attributes = @{NSFontAttributeName:tileLabel.font, NSParagraphStyleAttributeName:paragraphStyle.copy};

    CGFloat height = [tileLabel.text boundingRectWithSize:CGSizeMake(self.view.width-32, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attributes context:nil].size.height ;

//    CGFloat height =[self changeStationWidth:tileLabel.text anWidthTxtt:self.view.width-32 anfont:11];

    tileLabel.frame = CGRectMake(16, 0, self.view.width-32, height);

    [self.view addSubview:tileLabel];


本文标题:iOSUILabel设置行高
转载来源:http://cdkjz.cn/article/pdjeih.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220