您的位置:首页 > 其它

Lab、TextView文字两端对齐(中英文、标点、空格换行)

2017-04-10 17:11 453 查看
网上找了半天大部分都有各种各样的毛病。。话不多说,先看效果






代码附上:

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

-(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];
*//////
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  textview lab
相关文章推荐