博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Lab、TextView文字两端对齐(中英文、标点、空格换行)
阅读量:4136 次
发布时间:2019-05-25

本文共 914 字,大约阅读时间需要 3 分钟。

网上找了半天大部分都有各种各样的毛病。。话不多说,先看效果

代码附上:

/***********

-(NSAttributedString *)setTextString:(NSString *)text{

        

   NSMutableAttributedString *mAbStr = [[NSMutableAttributedStringalloc]initWithString:text];

   NSMutableParagraphStyle *npgStyle = [[NSMutableParagraphStylealloc]init];

    npgStyle.alignment =NSTextAlignmentJustified;

    npgStyle.paragraphSpacing =11.0;

    npgStyle.paragraphSpacingBefore =10.0;

    npgStyle.firstLineHeadIndent =0.0;

    npgStyle.headIndent =0.0;

   NSDictionary *dic = @{

                         NSForegroundColorAttributeName:[UIColorcolorWithHexString:@"6a3906"],

                         NSFontAttributeName:[UIFontsystemFontOfSize:15.0],

                         NSParagraphStyleAttributeName :npgStyle,

                         NSUnderlineStyleAttributeName :[NSNumbernumberWithInteger:NSUnderlineStyleNone]

                       };

    [mAbStrsetAttributes:dicrange:NSMakeRange(0, mAbStr.length)];

   NSAttributedString *attrString = [mAbStrcopy];

   return attrString;

}

*/

引用直接

/*****

text.attributedText = [selfsetTextString:String];

*//

你可能感兴趣的文章
mysql数据文件介绍
查看>>
python zlib
查看>>
iptables简介
查看>>
iptables优先顺序
查看>>
iptables DNAT 与 SNAT 详解
查看>>
Change Switch Mode to Interface Mode in Fortigate FortiOS 5
查看>>
数据包在内核态得捕获、修改和转发
查看>>
mips qemu
查看>>
linux内核调试环境的搭建(使用qemu)
查看>>
ESXi的路由特性
查看>>
谢希仁 计算机网络第五版下载地址
查看>>
HTTP隧道技术工具Reduh穿透防火墙
查看>>
动态规划:从新手到专家
查看>>
netfilter的抓包程序
查看>>
Fortinet Single Sign On Stack Overflow
查看>>
ELF文件的加载和动态链接过程
查看>>
ELF重定位类型分析(1-3, 总结)加评版
查看>>
perl snmp get
查看>>
cisco snmp copy-config-oid
查看>>
perl udp socket program
查看>>