• 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];
  • 相关阅读:
    compareTo冒泡比较时间字符串
    RestTemplate
    poi 处理空单元格
    Linux执行Java文件
    cmd 运行 java 文件
    @RequestParam 引发的编译问题
    linux 下安装与使用
    ajax请求 Provisional headers are show
    JWT加密
    Web API Filter
  • 原文地址:https://www.cnblogs.com/benbenzhu/p/3885656.html
Copyright © 2020-2023  润新知