zoukankan      html  css  js  c++  java
  • NSAttributedString设置行间距,间接设置了uilabel的行间距

     假设有UIlabel实例:_testLabel

     NSString * testString = @"明月当空,隐隐约约听到低吟,似有若无。面对大千世界的奢华糜烂,还不如在这一方小城,静静品一杯茗香。只是,经历了人间的风风雨雨,她早已不是当初那朵出淤泥而不染的莲花。明月当空,隐隐约约听到低吟,似有若无。面对大千世界的奢华糜烂,还不如在这一方小城,静静品一杯茗香。只是,经历了人间的风风雨雨,她早已不是当初那朵出淤泥而不染的莲花。明月当空,隐隐约约听到低吟,似有若无。面对大千世界的奢华糜烂,还不如在这一方小城,静静品一杯茗香。只是,经历了人间的风风雨雨,她早已不是当初那朵出淤泥而不染的莲花。";
        
        NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:testString];
        NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        [paragraphStyle setLineSpacing:15];
        
        [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [testString length])];
        
        [_testLabel setAttributedText:attributedString];
  • 相关阅读:
    bzoj1096: [ZJOI2007]仓库建设
    bzoj3289: Mato的文件管理
    bzoj1878: [SDOI2009]HH的项链
    bzoj1295: [SCOI2009]最长距离
    bzoj1056: [HAOI2008]排名系统 && 1862: [Zjoi2006]GameZ游戏排名系统
    vijosP1026毒药?解药?
    bzoj1293: [SCOI2009]生日礼物
    bzoj1483: [HNOI2009]梦幻布丁
    PCB开窗
    3W原则
  • 原文地址:https://www.cnblogs.com/benbenzhu/p/3885656.html
Copyright © 2011-2022 走看看