UILabel的自適應 及 富文本

UILabel的自適應

UILabel的自動換行
UILabel * examp_LB = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, 150)];
examp_LB.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0 alpha:0.3f];  // 偏“黃色”
examp_LB.text = @"abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz";
// 自動換行
examp_LB.numberOfLines = 0;  //必須設置為0行用踩,才會自動換行
examp_LB.lineBreakMode = NSLineBreakByCharWrapping;  //結(jié)尾時锡垄,按“字符”換行
[self.view addSubview:examp_LB];


NSLineBreakMode枚舉:

// NSParagraphStyle
typedef NS_ENUM(NSInteger, NSLineBreakMode) {
    NSLineBreakByWordWrapping = 0,      // Wrap at word boundaries, default
    NSLineBreakByCharWrapping,           // Wrap at character boundaries
    NSLineBreakByClipping,              // Simply clip
    NSLineBreakByTruncatingHead,           // Truncate at head of line: "...wxyz"
    NSLineBreakByTruncatingTail,           // Truncate at tail of line: "abcd..."
    NSLineBreakByTruncatingMiddle       // Truncate middle of line:  "ab...yz"
} NS_ENUM_AVAILABLE(10_0, 6_0);



幾種UILabel高度 對應的效果:

UILabel * examp_LB = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, 50)];

效果:裝不下 (裝不完)

字符串 裝不完

UILabel * examp_LB = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, 100)];

效果:裝下,剩一點點空間

字符串 裝完碾盟,僅剩一點點空間

UILabel * examp_LB = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, 150)];

效果:裝下妆丘,多出了很多空間

字符串 裝完锄俄,多出了很多空間

缺點:自己必須 保證UILabel所設置的高度完全 高于 所承載 字體的高度。否則會 裝不下勺拣!


UILabel的寬度自適應

使用寬度自適應時奶赠,(為了美觀????)一般都會設置字符串 居中:設置“textAlignment”為“NSTextAlignmentCenter

示例:

UILabel * examp_LB2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 200, self.view.frame.size.width, 50)];
examp_LB2.backgroundColor = [UIColor colorWithRed:1 green:0 blue:1 alpha:0.2f];
examp_LB2.text = @"abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz";
examp_LB2.adjustsFontSizeToFitWidth = YES;           //自適應 寬度
[self.view addSubview:examp_LB2];

效果:字符串 會全部 顯示在里面

字符串 會全部顯示在Label里面



“更改了字符串 長度,是其長度 減小后”的效果:

examp_LB2.text = @"abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcde";

效果:字符串長度 減短后

長度上 填滿了Label

examp_LB2.text = @"abcdefghijk";

效果:字符串長度非常短時药有,不能完全填滿Label的長度

字符串長度非常短時 不能完全填滿




對 UILabel的寬度 進行更改

UILabel * examp_LB3 = [[UILabel alloc] initWithFrame:CGRectMake(0, 260, 150, 50)];
examp_LB3.backgroundColor = [UIColor colorWithRed:1 green:0 blue:1 alpha:0.2f];
examp_LB3.text = @"abcdefghijk";
examp_LB3.textAlignment = NSTextAlignmentCenter;     //字跡 居中
examp_LB3.adjustsFontSizeToFitWidth = YES;           //自適應 寬度
[self.view addSubview:examp_LB3];

效果:裝完

屏幕快照 2017-01-18 下午10.01.35.png

UILabel * examp_LB3 = [[UILabel alloc] initWithFrame:CGRectMake(0, 260, 100, 50)];

效果:有些許的空白


UILabel * examp_LB3 = [[UILabel alloc] initWithFrame:CGRectMake(0, 260, 150, 50)];

效果:有許多的空白





UILabel換行毅戈、自適應寬度
UILabel * examp_LB4 = [[UILabel alloc] initWithFrame:CGRectMake(0, 320, self.view.frame.size.width, 50)];
examp_LB4.backgroundColor = [UIColor colorWithRed:1 green:0 blue:1 alpha:0.2f];
examp_LB4.text = @"abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz";
examp_LB4.numberOfLines = 0;                      //行數(shù)設置為0
examp_LB4.adjustsFontSizeToFitWidth = YES;        //自適應 寬度
[self.view addSubview:examp_LB4];


??:不能設置其 換行模式的屬性!!!!! 否則“adjustsFontSizeToFitWidth”的設置 將變?yōu)?strong>無效!

UILabel * examp_LB5 = [[UILabel alloc] initWithFrame:CGRectMake(0, 380, self.view.frame.size.width, 50)];
examp_LB5.backgroundColor = [UIColor colorWithRed:1 green:0 blue:1 alpha:0.2f];
examp_LB5.text = @"abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz";
examp_LB5.numberOfLines = 0;
examp_LB5.lineBreakMode = NSLineBreakByCharWrapping; //(??????)

// 由于設置了換行模式塑猖,自適應寬度變?yōu)闊o效
examp_LB5.adjustsFontSizeToFitWidth = YES;           //自適應 寬度
[self.view addSubview:examp_LB5];

效果:

examp_LB4竹祷、examp_LB5 的 效果


UILabel的 ??完全自適應??

要使用到 如下方法:

- (CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)options attributes:(nullable NSDictionary<NSString *, id> *)attributes context:(nullable NSStringDrawingContext *)context NS_AVAILABLE(10_11, 7_0);

來記錄下UILabel的frame,再讀取出來(返回類型: CGRect) 使用 其frame羊苟!

在使用的類里 對方法改寫后,如下:

// 傳入 文字感憾、字體和最大尺寸蜡励,即可得到寬、高
- (CGSize)sizeWithText:(NSString *)text andFont:(UIFont *)font maxSize:(CGSize)maxSize
{
    NSDictionary *attrs = @{NSFontAttributeName : font};
    return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
}


// 傳入文字阻桅、字體和最大寬度凉倚,即可得到寬、高
-(CGSize)sizeWithText:(NSString *)text font:(UIFont *)font maxW:(CGFloat)maxW
{
    NSMutableDictionary *attrs=[NSMutableDictionary dictionary];
    attrs[NSFontAttributeName]=font;

    CGSize maxSize=CGSizeMake(maxW, MAXFLOAT);
    return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
}
// 傳入文字嫂沉、字體 (默認:最大寬度)
- (CGSize)sizeWithText:(NSString *)text font:(UIFont *)font
{
    return [self sizeWithText:text font:font maxW:MAXFLOAT];
}


在“viewDidLoad { }”里面:

UILabel * examp_LB6 = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, self.view.frame.size.width, 50)];
examp_LB6.backgroundColor = [UIColor colorWithRed:1 green:0 blue:1 alpha:0.2f];

// 自動換行
examp_LB6.numberOfLines = 0;
examp_LB6.lineBreakMode = NSLineBreakByCharWrapping;
[self.view addSubview:examp_LB6];

// 設置自適應 所需字串
NSString * str = @"abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz";
examp_LB6.text = str;

// 設置自適應 所需字體
UIFont *font = [UIFont fontWithName:@"Arial" size:12];
examp_LB6.font = font;

如下是三種方法的調(diào)用:

  • 1.傳入 文字稽寒、字體和最大尺寸,即可得到寬趟章、高

      // 傳入 文字杏糙、字體和最大尺寸慎王,即可得到寬、高
      CGSize labelsize = [self sizeWithText:str andFont:font maxSize:CGSizeMake(self.view.frame.size.width, 100)];
      examp_LB6.frame = CGRectMake(examp_LB6.frame.origin.x,examp_LB6.frame.origin.y, labelsize.width, labelsize.height);
    

效果:

傳入 文字宏侍、字體和最大尺寸


  • 2.傳入文字赖淤、字體和最大寬度,即可得到寬谅河、高

      // 傳入文字咱旱、字體和最大寬度,即可得到寬绷耍、高
      CGSize labelsize = [self sizeWithText:str font:font maxW:290];  //限定寬度
      examp_LB6.frame = CGRectMake(examp_LB6.frame.origin.x,examp_LB6.frame.origin.y, labelsize.width, labelsize.height);
    

效果:

傳入文字吐限、字體和最大寬度(**290**)


  • 3.傳入文字、字體 (默認:最大寬度)

      // 傳入文字褂始、字體 (默認:最大寬度)
      CGSize labelsize = [self sizeWithText:str font:font];
      examp_LB6.frame = CGRectMake(examp_LB6.frame.origin.x,examp_LB6.frame.origin.y, labelsize.width, labelsize.height);
    

效果:會得到Label的最大長度

傳入文字诸典、字體 (默認:最大寬度)

顯示出來是 屏幕的寬度。打上斷點 病袄,查看Label的最大長度:

Label的最大長度

當然 使用系統(tǒng)的“視圖位置關系”查看方法“Debug View Hierarchy” 枉然搂赋,是不能看到屏幕外的視圖。

點擊益缠,查看視圖位置關系

只能看到屏幕內(nèi)的視圖


使用一款叫“Reveal”的軟件脑奠,可以查看 屏幕外的視圖:
使用“**Reveal**”軟件,查看到 **屏幕外**的視圖


Reveal 下載地址:https://revealapp.com/download/
當然 我用的是 破解版~ ??????????????

Reveal-----視圖大小幅慌、位置關系 查看及調(diào)試宋欺。Reveal使用說明的文章 網(wǎng)上有很多,就不詳述了~



當然也可以直接 使用

- (CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)options attributes:(nullable NSDictionary<NSString *, id> *)attributes context:(nullable NSStringDrawingContext *)context NS_AVAILABLE(10_11, 7_0);

方法 所返回的“CGRect結(jié)構(gòu)體胰伍。


代碼如下:

NSDictionary *attribute_Dict = @{NSFontAttributeName: font};// 字體的字典
CGRect label_Rect = [str boundingRectWithSize:CGSizeMake(self.view.frame.size.width, 0) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading | NSStringDrawingTruncatesLastVisibleLine attributes:attribute_Dict context:nil];
float label_height = label_Rect.size.height;
float label_width = label_Rect.size.width;
examp_LB6.frame = CGRectMake(examp_LB6.frame.origin.x,examp_LB6.frame.origin.y, label_width, label_height);


效果:



當設置字符串居中 時:

examp_LB6.textAlignment = NSTextAlignmentCenter;     //字跡 居中

效果:

字符串的__字跡__ **居中**:NSTextAlignmentCenter


下面是更改字符串的長度 示例齿诞,你就會清楚 UILabel的高、寬 完全自適應B钭狻5昏尽!I但汞!

NSString * str = @"abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcde";

效果:



長度 足夠短時:

// 長度 足夠短時  (寬度自適應)
NSString * str = @"abcdefghi";

效果:UILabel的高、寬 自適應

UILabel的**高互站、寬 自適應**






UILabel使用 富文本

Text Kit能夠很簡單實現(xiàn)一些復雜的文本 樣式以及布局私蕾,而Text Kit富文本框架用到的核心數(shù)據(jù)結(jié)構(gòu)就是屬性化字符串NSAttributeString
Text Kit指的是UIKit框架中用于提供高質(zhì)量排版服務的一些類和協(xié)議,它讓程序能夠存儲胡桃,排版和顯示文本信息踩叭,并支持排版所需要的所有特性(包括字距調(diào)整、連寫、換行和對齊等) 容贝。


1.初始化方法

- (instancetype)initWithString:(NSString *)str;

- (instancetype)initWithString:(NSString *)str attributes:(nullable NSDictionary<NSString *, id> *)attrs;

- (instancetype)initWithAttributedString:(NSAttributedString *)attrStr;
//使用NSAttributedString初始化自脯,跟NSMutableString,NSString類似


NSMutableAttributedString的屬性設置:

//為某一范圍內(nèi)文字設置多個屬性
- (void)setAttributes:(NSDictionary *)attrs range:(NSRange)range;
//為某一范圍內(nèi)文字添加某個屬性
- (void)addAttribute:(NSString *)name value:(id)value range:(NSRange)range;
//為某一范圍內(nèi)文字添加多個屬性
- (void)addAttributes:(NSDictionary *)attrs range:(NSRange)range;

//移除某范圍內(nèi)的某個屬性
- (void)removeAttribute:(NSString *)name range:(NSRange)range;



2.常見的屬性及說明

NSFontAttributeName                字體屬性(字體嗤疯、大小)冤今。        默認值:字體:Helvetica(Neue) 字號:12
NSForegroundColorAttributeNam      字體顏色,取值為 UIColor對象茂缚。        默認值為黑色
NSBackgroundColorAttributeName     字體所在區(qū)域背景顏色戏罢,取值為 UIColor對象。        默認值為nil, 透明色

NSLigatureAttributeName            連體屬性脚囊,取值為NSNumber 對象(整數(shù)),0 表示沒有連體字符悔耘,1 表示使用默認的連體字符
NSKernAttributeName                設定字符間距讲岁,取值為 NSNumber 對象(整數(shù)),正值間距加寬衬以,負值間距變窄

NSStrikethroughStyleAttributeName  刪除線缓艳,取值為 NSNumber 對象(整數(shù))
NSStrikethroughColorAttributeName  刪除線顏色,取值為 UIColor 對象看峻。        默認值為黑色
NSUnderlineStyleAttributeName      下劃線阶淘,取值為 NSNumber 對象(整數(shù)),枚舉常量 NSUnderlineStyle中的值互妓,與刪除線類似
NSUnderlineColorAttributeName      下劃線顏色溪窒,取值為 UIColor 對象。        默認值為黑色
NSStrokeWidthAttributeName         設置筆畫寬度冯勉,取值為 NSNumber 對象(整數(shù))澈蚌,負值填充效果,正值中空效果
NSStrokeColorAttributeName         填充部分顏色灼狰,不是字體顏色宛瞄,取值為 UIColor 對象

NSShadowAttributeName              設置陰影屬性,取值為 NSShadow 對象

NSTextEffectAttributeName          設置文本特殊效果交胚,取值為 NSString 對象坛悉,目前只有圖版印刷效果可用

NSBaselineOffsetAttributeName      設置基線偏移值,取值為 NSNumber (float),正值上偏承绸,負值下偏
NSObliquenessAttributeName         設置字形傾斜度,取值為 NSNumber (float),正值右傾挣轨,負值左傾
NSExpansionAttributeName           設置文本橫向拉伸屬性军熏,取值為 NSNumber (float),正值橫向拉伸文本,負值橫向壓縮文本

NSWritingDirectionAttributeName    設置文字書寫方向卷扮,從左向右書寫或者從右向左書寫
NSVerticalGlyphFormAttributeName   設置文字排版方向荡澎,取值為 NSNumber 對象(整數(shù))均践,0 表示橫排文本,1 表示豎排文本

NSAttachmentAttributeName          設置文本附件,取值為NSTextAttachment對象,常用于文字圖片混排

NSParagraphStyleAttributeName      設置文本段落排版格式摩幔,取值為 NSParagraphStyle 對象

NSLinkAttributeName                設置鏈接屬性彤委,點擊后調(diào)用瀏覽器打開指定URL地址

為富文本添加鏈接:iOS開發(fā)——超鏈接富文本


富文本的 屬性展示 示例 網(wǎng)址:http://www.itnose.net/detail/6177538.html



舉個??:
// 垃圾代碼部分
UILabel * examp_Attrb_LB1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, self.view.frame.size.width, 50)];
examp_Attrb_LB1.backgroundColor = [UIColor colorWithRed:0.5 green:1 blue:0 alpha:0.2f];
[self.view addSubview:examp_Attrb_LB1];


UILabel * examp_Attrb_LB2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 110, self.view.frame.size.width, 50)];
examp_Attrb_LB2.backgroundColor = [UIColor colorWithRed:0.5 green:1 blue:0 alpha:0.2f];
[self.view addSubview:examp_Attrb_LB2];


UILabel * examp_Attrb_LB3 = [[UILabel alloc] initWithFrame:CGRectMake(0, 170, self.view.frame.size.width, 50)];
examp_Attrb_LB3.backgroundColor = [UIColor colorWithRed:0.5 green:1 blue:0 alpha:0.2f];
[self.view addSubview:examp_Attrb_LB3];


UILabel * examp_Attrb_LB4 = [[UILabel alloc] initWithFrame:CGRectMake(0, 260, self.view.frame.size.width, 50)];
examp_Attrb_LB4.backgroundColor = [UIColor colorWithRed:0.5 green:1 blue:0 alpha:0.2f];
[self.view addSubview:examp_Attrb_LB4];


UILabel * examp_Attrb_LB5 = [[UILabel alloc] initWithFrame:CGRectMake(0, 320, self.view.frame.size.width, 50)];
examp_Attrb_LB5.backgroundColor = [UIColor colorWithRed:0.5 green:1 blue:0 alpha:0.2f];
[self.view addSubview:examp_Attrb_LB5];


UILabel * examp_Attrb_LB6 = [[UILabel alloc] initWithFrame:CGRectMake(0, 380, self.view.frame.size.width, 150)];
examp_Attrb_LB6.backgroundColor = [UIColor colorWithRed:0.5 green:1 blue:0 alpha:0.2f];
[self.view addSubview:examp_Attrb_LB6];








//《《《《《《《《《《《《《 進入主題 》》》》》》》》》》》》》

// 富文本 字符串1
NSAttributedString * attrStr1 = [[NSAttributedString alloc] initWithString:@"abcdefghij"]; // 幾近無用??   


// 不可變 富文本2    (附帶設置 富文本屬性(??全體??的屬性)   )
NSAttributedString * attrStr2 = [[NSAttributedString alloc] initWithString:@"hijklmnopqr" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:30.f],NSForegroundColorAttributeName:RGB(137, 198, 41)}];

// 不可變 富文本3   (??復制??一份富文本 )
NSAttributedString * attrStr3 = [[NSAttributedString alloc] initWithAttributedString:attrStr2]; // ??復制??一份富文本


//=======================================================
// 可變 富文本4
NSMutableAttributedString * attrStr4 = [[NSMutableAttributedString alloc] initWithAttributedString:attrStr2];
// 獲取“mno”字符串     ??所在范圍??    
NSRange rag_1 = [attrStr4.string localizedStandardRangeOfString:@"mno"];
// 添加       “mno”字符串所在范圍 字體  屬性
[attrStr4 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10.f] range:rag_1];

//=======================================================
// 可變 富文本5
NSMutableAttributedString * attrStr5 = [[NSMutableAttributedString alloc] initWithString:@"stuvwxyz"];
// 要添加或更改屬性 的字典
NSDictionary * attr_Dict = @{NSForegroundColorAttributeName:[UIColor orangeColor],
                             NSUnderlineStyleAttributeName:[NSNumber numberWithFloat:1.0]
                            };    //字體顏色 及 下劃線

// ??添加?? 范圍內(nèi) 富文本屬性
[attrStr5 addAttributes:attr_Dict range:NSMakeRange(0, attrStr5.length)]; // 整個字符串(NSMakeRange(0, attrStr5.length))的范圍

// 要添加或更改屬性 的字典
NSDictionary * attr_Dict2 = @{NSBackgroundColorAttributeName:[UIColor cyanColor],
                              NSForegroundColorAttributeName:[UIColor blueColor],
                              NSStrikethroughStyleAttributeName:[NSNumber numberWithFloat:1.0]
                            };     //背景色、字體顏色 及 刪除線

// 要添加或更改屬性的 范圍
NSRange rag_2 = NSMakeRange(2, 2);
// ??設置?? 范圍內(nèi) 富文本屬性
[attrStr5 setAttributes:attr_Dict2 range:rag_2];

//=======================================================
// 可變 富文本6
NSMutableAttributedString * attrStr6 = [[NSMutableAttributedString alloc] initWithString:@"abcdefghijklmnopqrstuvwxyz"];
// 隨機色Label
for (int i = 0; i < attrStr6.string.length; i ++) {
    // 所有更改屬性 的字典
    NSDictionary * attr_Dict = @{NSForegroundColorAttributeName:[UIColor colorWithRed:arc4random()%256/255.f green:arc4random()%256/255.f blue:arc4random()%256/255.f alpha:1],
                                 NSFontAttributeName:[UIFont systemFontOfSize:(arc4random()%20+30)/1.f]
                                 }; // 字體:隨機顏色或衡、隨機大小

    // 要添加或更改屬性的 范圍
    NSRange rag = NSMakeRange(i, 1);
    // ??設置?? 范圍內(nèi) 富文本屬性
    [attrStr6 setAttributes:attr_Dict range:rag];
}



// Label添加 富文本字符串
examp_Attrb_LB1.attributedText = attrStr1;
examp_Attrb_LB2.attributedText = attrStr2;
examp_Attrb_LB3.attributedText = attrStr3;    
examp_Attrb_LB4.attributedText = attrStr4;
examp_Attrb_LB5.attributedText = attrStr5;
examp_Attrb_LB6.attributedText = attrStr6;

效果:

各Label 的富文本效果圖



加上 自動換行代碼后焦影,examp_Attrb_LB6實現(xiàn)換行:

// 自動換行
examp_Attrb_LB6.numberOfLines = 0;
examp_Attrb_LB6.lineBreakMode = NSLineBreakByCharWrapping;

效果:

UILabel設置為自動換行后 的效果



富文本在UITextViewUITextField中的示例:

UITextView * tv = [[UITextView alloc] initWithFrame:CGRectMake(9, 20, 100, 200)];
tv.backgroundColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:0.2f];
tv.attributedText = attrStr6;
[self.view addSubview:tv];



UITextField * tf = [[UITextField alloc] initWithFrame:CGRectMake(10, 260, 200, 20)];
tf.backgroundColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:0.2f];
tf.attributedText = attrStr6;
[self.view addSubview:tf];

效果:

**UITextView**封断、**UITextField**中的示例

在字符串后面添加 字符串時斯辰,后面的富文本 會復制 上一個富文本字符的字體顏色大小坡疼。




更多方法和屬性說明 詳見蘋果官方說明文檔https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSMutableAttributedString_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40003689



一般富文本也就簡單的顯示在 一彬呻、兩處 地方,在定制控件封裝好就可以了柄瑰。
當然你自己可以給UILabel 加個使用富文本的類別~














goyohol's essay

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末闸氮,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子教沾,更是在濱河造成了極大的恐慌蒲跨,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,378評論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件详囤,死亡現(xiàn)場離奇詭異财骨,居然都是意外死亡,警方通過查閱死者的電腦和手機藏姐,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,970評論 3 399
  • 文/潘曉璐 我一進店門隆箩,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人羔杨,你說我怎么就攤上這事捌臊。” “怎么了兜材?”我有些...
    開封第一講書人閱讀 168,983評論 0 362
  • 文/不壞的土叔 我叫張陵理澎,是天一觀的道長。 經(jīng)常有香客問我曙寡,道長糠爬,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,938評論 1 299
  • 正文 為了忘掉前任举庶,我火速辦了婚禮执隧,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己镀琉,他們只是感情好峦嗤,可當我...
    茶點故事閱讀 68,955評論 6 398
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著屋摔,像睡著了一般烁设。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上钓试,一...
    開封第一講書人閱讀 52,549評論 1 312
  • 那天装黑,我揣著相機與錄音,去河邊找鬼亚侠。 笑死曹体,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的硝烂。 我是一名探鬼主播箕别,決...
    沈念sama閱讀 41,063評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼滞谢!你這毒婦竟也來了串稀?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,991評論 0 277
  • 序言:老撾萬榮一對情侶失蹤狮杨,失蹤者是張志新(化名)和其女友劉穎母截,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體橄教,經(jīng)...
    沈念sama閱讀 46,522評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡清寇,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,604評論 3 342
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了护蝶。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片华烟。...
    茶點故事閱讀 40,742評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖持灰,靈堂內(nèi)的尸體忽然破棺而出盔夜,到底是詐尸還是另有隱情,我是刑警寧澤堤魁,帶...
    沈念sama閱讀 36,413評論 5 351
  • 正文 年R本政府宣布喂链,位于F島的核電站,受9級特大地震影響妥泉,放射性物質(zhì)發(fā)生泄漏椭微。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 42,094評論 3 335
  • 文/蒙蒙 一盲链、第九天 我趴在偏房一處隱蔽的房頂上張望赏表。 院中可真熱鬧检诗,春花似錦、人聲如沸瓢剿。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,572評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽间狂。三九已至,卻和暖如春火架,著一層夾襖步出監(jiān)牢的瞬間鉴象,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,671評論 1 274
  • 我被黑心中介騙來泰國打工何鸡, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留纺弊,地道東北人。 一個月前我還...
    沈念sama閱讀 49,159評論 3 378
  • 正文 我出身青樓骡男,卻偏偏與公主長得像淆游,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子隔盛,可洞房花燭夜當晚...
    茶點故事閱讀 45,747評論 2 361

推薦閱讀更多精彩內(nèi)容

  • 發(fā)現(xiàn) 關注 消息 iOS 第三方庫犹菱、插件、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關注 2017.06.26 09:4...
    肇東周閱讀 12,123評論 4 61
  • 雨下吮炕,依舊 看風聲腊脱,聽水流 靜默,守候 雨滴啪嗒龙亲,是傘的招手 小道靜謐陕凹,鮮有問候 路燈,昏黃 人影鳄炉,徜徉 燈下...
    夜雪初霽suny閱讀 110評論 0 0
  • 這是一個沖動消費十分盛行的時代杜耙,特別是在大城市里,人們對物質(zhì)追求達到了空前的高度迎膜。我們吃好的泥技,穿好的,懶得走路磕仅,車...
    真墨流歌閱讀 351評論 0 3
  • 我是科學家培育的孩子珊豹, 我的職責就是除草。 當你把地種完榕订, 用噴壺或機車噴上我店茶, 這一塊地的草不會長出來, 我是草...
    旖旎i閱讀 287評論 0 1