UIlabel - 富文本属性】的更多相关文章

1.NSKernAttributeName: @10 调整字句 kerning 字句调整 2.NSFontAttributeName : [UIFont systemFontOfSize:_fontSize] 设置字体 3.NSForegroundColorAttributeName :[UIColor redColor] 设置文字颜色 4.NSParagraphStyleAttributeName : paragraph 设置段落样式 5.NSMutableParagraphStyle *pa…
之前文本整理有一点乱,这边重新整理一下,下面是效果图,一共两个UILabel, 富文本整理: /*NSForegroundColorAttributeName设置字体颜色,对象UIColor; NSParagraphStyleAttributeName设置段落格式,对象NSMutableParagraphStyle; NSFontAttributeName设置字体,对象UIFont; NSBackgroundColorAttributeName设置背景颜色,对象UIColor; NSKernAt…
本文转载至 http://www.jianshu.com/p/5d24d22f99c3 富文本 NSString *str = @"人生若只如初见,何事秋风悲画扇.\n等闲变却故人心,却道故人心易变.\n骊山语罢清宵半,泪雨霖铃终不怨.\n何如薄幸锦衣郎,比翼连枝当日愿."; NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:str]; attrStr添加字体和设…
// NSFontAttributeName 设置字体属性,默认值:字体:Helvetica(Neue) 字号:12 // NSForegroundColorAttributeNam 设置字体颜色,取值为 UIColor对象,默认值为黑色 // NSBackgroundColorAttributeName 设置字体所在区域背景颜色,取值为 UIColor对象,默认值为nil, 透明色 // NSLigatureAttributeName 设置连体属性,取值为NSNumber 对象(整数),0 表…
简易使用UILabel的富文本 使用效果: 源码: NSString+YX.h    NSString+YX.m // // NSString+YX.h // YXKit // // Copyright (c) 2014年 Y.X. All rights reserved. // #import <Foundation/Foundation.h> #import "ConfigAttributedString.h" @interface NSString (YX) // 创…
/** 方法说明:设置label的富文本属性 参数说明:contentStr富文本内容 textColor字体颜色 rangeSet设置字体颜色及大小的位置 */ - (UILabel *)backfwbLabelWithText:(NSString *)contentStr textColor:(NSString *)textColor rangeSet:(NSInteger)rangeSet { // 文本信息 NSString *str = contentStr; NSMutableAtt…
/NSMutableParagraphStyle/NSMutableAttributedString 组合使 NSString * titlestr=@"日产GT-R"; NSMutableParagraphStyle * paragraphstyle0 =[[NSMutableParagraphStyle alloc]init]; [paragraphstyle0 setLineSpacing:]; paragraphstyle0.alignment = NSTextAlignmen…
agreeDeal = UILabel() //富文本,不同字体颜色大小和颜色 let labelString = "登录注册,表示您同意<服务条款及隐私政策>"as NSString let rang = labelString.rangeOfString("<") let firstRang = NSMakeRange(0, rang.location) let secondRang = NSMakeRange(rang.location, l…
有时候开发中我们为了样式好看, 需要对文本设置富文本属性, 设置完后那么怎样计算其高度呢, 很简单, 方法如下: - (NSInteger)hideLabelLayoutHeight:(NSString *)content withTextFontSize:(CGFloat)mFontSize { NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; paragraphStyle.lin…
若想对UILabel添加图片,那么就需要使用NSMutableAttributedString来定义先定义一个普通的label UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(, , self.view.frame.size.width-, )]; lab.numberOfLines = ; [self.view addSubview:lab]; 然后对其定义 //创建富文本 NSMutableAttributedString *a…