版本記錄
版本號(hào) | 時(shí)間 |
---|---|
V1.0 | 2018.03.31 |
前言
iOS圈內(nèi)有幾個(gè)人大家基本都知道,比如說王巍、唐巧谨娜,還有YYKit框架的作者現(xiàn)任職于滴滴的郭曜源 - ibireme等为流。這里有一篇唐巧對(duì)他的專訪呕屎,還有他的 GitHub - Yaoyuan 和 博客,這里貼出來框架YYKit 框架艺谆。接下來幾篇我們就一起來看一下這個(gè)框架榨惰。感興趣的可以看上面寫的幾篇。
1. YYKit源碼探究(一) —— 基本概覽
2. YYKit源碼探究(二) —— NSString分類之Hash(一)
3. YYKit源碼探究(三) —— NSString分類之Encode and decode(二)
4. YYKit源碼探究(四) —— NSString分類之Drawing(三)
5. YYKit源碼探究(五) —— NSString分類之Regular Expression(四)
6. YYKit源碼探究(六) —— NSString分類之NSNumber Compatible(五)
7. YYKit源碼探究(七) —— NSString分類之Utilities(六)
8. YYKit源碼探究(八) —— NSNumber分類(一)
9. YYKit源碼探究(九) —— UIFont分類之架構(gòu)分析和Font Traits(一)
10. YYKit源碼探究(十) —— UIFont分類之Create font(二)
11. YYKit源碼探究(十一) —— UIFont分類之Load and unload font(三)
12. YYKit源碼探究(十二) —— UIFont分類之Dump font data(四)
13. YYKit源碼探究(十三) —— UIImage分類之框架結(jié)構(gòu)和Create image部分(一)
14. YYKit源碼探究(十四) —— UIImage分類之Image Info(二)
15. YYKit源碼探究(十五) —— UIImage分類之Modify Image(三)
16. YYKit源碼探究(十六) —— UIImage分類之Image Effect(四)
17. YYKit源碼探究(十七) —— UIImageView分類之架構(gòu)和image部分(一)
18. YYKit源碼探究(十八) —— UIImageView分類之highlight image部分(二)
19. YYKit源碼探究(十九) —— UIScreen分類(一)
20. YYKit源碼探究(二十) —— UIScrollView分類(一)
21. YYKit源碼探究(二十一) —— UITableView分類(一)
22. YYKit源碼探究(二十二) —— UITextField分類(一)
23. YYKit源碼探究(二十三) —— UIView分類(一)
24. YYKit源碼探究(二十四) —— UIPasteboard分類(一)
25. YYKit源碼探究(二十五) —— UIGestureRecognizer分類(一)
26. YYKit源碼探究(二十六) —— UIDevice分類框架及Device Information(一)
27. YYKit源碼探究(二十七) —— UIDevice分類之Network Information(二)
28. YYKit源碼探究(二十八) —— UIDevice分類之Disk Space(三)
29. YYKit源碼探究(二十九) —— UIDevice分類之Memory Information(四)
30. YYKit源碼探究(三十) —— UIDevice分類之CPU Information(五)
31. YYKit源碼探究(三十一) —— UIControl分類(一)
32. YYKit源碼探究(三十二) —— UIColor分類之Create a UIColor Object(一)
33. YYKit源碼探究(三十三) —— UIColor分類之Get color's description(二)
34. YYKit源碼探究(三十四) —— UIColor分類之Retrieving Color Information(三)
35. YYKit源碼探究(三十五) —— UIButton分類之image(一)
36. YYKit源碼探究(三十六) —— UIButton分類之background image(二)
37. YYKit源碼探究(三十七) —— UIBezierPath分類(一)
38. YYKit源碼探究(三十八) —— UIBarButtonItem分類(一)
39. YYKit源碼探究(三十九) —— UIApplication分類(一)
40. YYKit源碼探究(四十) —— NSTimer分類(一)
41. YYKit源碼探究(四十一) —— NSParagraphStyle分類(一)
42. YYKit源碼探究(四十二) —— NSObject分類之YYModel(一)
43. YYKit源碼探究(四十三) —— NSObject分類之KVO(二)
44. YYKit源碼探究(四十四) —— NSObject分類之Sending messages with variable parameters(三)
45. YYKit源碼探究(四十五) —— NSObject分類之Swap method (Swizzling)(四)
46. YYKit源碼探究(四十六) —— NSObject分類之Associate value(五)
47. YYKit源碼探究(四十七) —— NSObject分類之Other(六)
48. YYKit源碼探究(四十八) —— NSNotificationCenter分類(一)
49. YYKit源碼探究(四十九) —— NSKeyedUnarchiver分類(一)
50. YYKit源碼探究(五十) —— NSDictionary分類之Dictionary Convertor(一)
51. YYKit源碼探究(五十一) —— NSDictionary分類之Dictionary Value Getter(二)
52. YYKit源碼探究(五十二) —— NSDictionary分類之NSMutableDictionary(三)
53. YYKit源碼探究(五十三) —— NSDate分類之Component Properties(一)
54. YYKit源碼探究(五十四) —— NSDate分類之Date modify(二)
55. YYKit源碼探究(五十五) —— NSDate分類之Date Format(三)
56. YYKit源碼探究(五十六) —— NSData分類之Hash(一)
57. YYKit源碼探究(五十七) —— NSData分類之Encrypt and Decrypt(二)
58. YYKit源碼探究(五十八) —— NSData分類之Encode and decode(三)
59. YYKit源碼探究(五十九) —— NSData分類之Inflate and deflate(四)
60. YYKit源碼探究(六十) —— NSData分類之Others(五)
61. YYKit源碼探究(六十一) —— NSBundle分類(一)
62. YYKit源碼探究(六十二) —— NSAttributedString分類之基本(一)
63. YYKit源碼探究(六十三) —— NSAttributedString分類之Retrieving character attribute information(二)
64. YYKit源碼探究(六十四) —— NSAttributedString分類之Get character attribute as property(三)
65. YYKit源碼探究(六十五) —— NSAttributedString分類之Get paragraph attribute as property(四)
回顧
上一篇主要介紹了NSAttributedString
分類的Get paragraph attribute as property
部分静汤,這一篇主要看一下NSAttributedString
分類的Get YYText attribute as property
部分琅催。
API
下面我們看一下API
/**
The text shadow. (read-only)
@discussion Default value is nil (no shadow).
@discussion Get this property returns the first character's attribute.
@since YYKit:6.0
*/
@property (nullable, nonatomic, strong, readonly) YYTextShadow *textShadow;
- (nullable YYTextShadow *)textShadowAtIndex:(NSUInteger)index;
/**
The text inner shadow. (read-only)
@discussion Default value is nil (no shadow).
@discussion Get this property returns the first character's attribute.
@since YYKit:6.0
*/
@property (nullable, nonatomic, strong, readonly) YYTextShadow *textInnerShadow;
- (nullable YYTextShadow *)textInnerShadowAtIndex:(NSUInteger)index;
/**
The text underline. (read-only)
@discussion Default value is nil (no underline).
@discussion Get this property returns the first character's attribute.
@since YYKit:6.0
*/
@property (nullable, nonatomic, strong, readonly) YYTextDecoration *textUnderline;
- (nullable YYTextDecoration *)textUnderlineAtIndex:(NSUInteger)index;
/**
The text strikethrough. (read-only)
@discussion Default value is nil (no strikethrough).
@discussion Get this property returns the first character's attribute.
@since YYKit:6.0
*/
@property (nullable, nonatomic, strong, readonly) YYTextDecoration *textStrikethrough;
- (nullable YYTextDecoration *)textStrikethroughAtIndex:(NSUInteger)index;
/**
The text border. (read-only)
@discussion Default value is nil (no border).
@discussion Get this property returns the first character's attribute.
@since YYKit:6.0
*/
@property (nullable, nonatomic, strong, readonly) YYTextBorder *textBorder;
- (nullable YYTextBorder *)textBorderAtIndex:(NSUInteger)index;
/**
The text background border. (read-only)
@discussion Default value is nil (no background border).
@discussion Get this property returns the first character's attribute.
@since YYKit:6.0
*/
@property (nullable, nonatomic, strong, readonly) YYTextBorder *textBackgroundBorder;
- (nullable YYTextBorder *)textBackgroundBorderAtIndex:(NSUInteger)index;
/**
The glyph transform. (read-only)
@discussion Default value is CGAffineTransformIdentity (no transform).
@discussion Get this property returns the first character's attribute.
@since YYKit:6.0
*/
@property (nonatomic, readonly) CGAffineTransform textGlyphTransform;
- (CGAffineTransform)textGlyphTransformAtIndex:(NSUInteger)index;
下面一起仔細(xì)看一下。
1. @property (nullable, nonatomic, strong, readonly) YYTextShadow *textShadow; 和 - (nullable YYTextShadow *)textShadowAtIndex:(NSUInteger)index;
獲取文本陰影虫给,只讀屬性藤抡。默認(rèn)值是nil,沒有陰影抹估。
方法實(shí)現(xiàn)
- (YYTextShadow *)textShadow {
return [self textShadowAtIndex:0];
}
- (YYTextShadow *)textShadowAtIndex:(NSUInteger)index {
return [self attribute:YYTextShadowAttributeName atIndex:index];
}
- (id)attribute:(NSString *)attributeName atIndex:(NSUInteger)index {
if (!attributeName) return nil;
if (index > self.length || self.length == 0) return nil;
if (self.length > 0 && index == self.length) index--;
return [self attribute:attributeName atIndex:index effectiveRange:NULL];
}
2. @property (nullable, nonatomic, strong, readonly) YYTextShadow *textInnerShadow; 和 - (nullable YYTextShadow *)textInnerShadowAtIndex:(NSUInteger)index;
獲取文本inner陰影缠黍。默認(rèn)值是nil,沒有陰影药蜻。
方法實(shí)現(xiàn)
- (YYTextShadow *)textInnerShadow {
return [self textInnerShadowAtIndex:0];
}
- (YYTextShadow *)textInnerShadowAtIndex:(NSUInteger)index {
return [self attribute:YYTextInnerShadowAttributeName atIndex:index];
}
3. @property (nullable, nonatomic, strong, readonly) YYTextDecoration *textUnderline; 和 - (nullable YYTextDecoration *)textUnderlineAtIndex:(NSUInteger)index;
獲取文本下劃線瓷式,默認(rèn)值是nil,沒有下劃線语泽。
方法實(shí)現(xiàn)
- (YYTextDecoration *)textUnderline {
return [self textUnderlineAtIndex:0];
}
- (YYTextDecoration *)textUnderlineAtIndex:(NSUInteger)index {
return [self attribute:YYTextUnderlineAttributeName atIndex:index];
}
4. @property (nullable, nonatomic, strong, readonly) YYTextDecoration *textStrikethrough; 和 - (nullable YYTextDecoration *)textStrikethroughAtIndex:(NSUInteger)index;
獲取文本的strikethrough
贸典,只讀屬性,默認(rèn)值為nil踱卵。
方法實(shí)現(xiàn)
- (YYTextDecoration *)textStrikethrough {
return [self textStrikethroughAtIndex:0];
}
- (YYTextDecoration *)textStrikethroughAtIndex:(NSUInteger)index {
return [self attribute:YYTextStrikethroughAttributeName atIndex:index];
}
5. @property (nullable, nonatomic, strong, readonly) YYTextBorder *textBorder; 和 - (nullable YYTextBorder *)textBorderAtIndex:(NSUInteger)index;
獲取文本的邊界廊驼。默認(rèn)值nil,沒有邊界惋砂。
方法實(shí)現(xiàn)
- (YYTextBorder *)textBorder {
return [self textBorderAtIndex:0];
}
- (YYTextBorder *)textBorderAtIndex:(NSUInteger)index {
return [self attribute:YYTextBorderAttributeName atIndex:index];
}
6. @property (nullable, nonatomic, strong, readonly) YYTextBorder *textBackgroundBorder; 和 - (nullable YYTextBorder *)textBackgroundBorderAtIndex:(NSUInteger)index;
獲取文本背景邊界妒挎,默認(rèn)是nil,沒有邊界西饵。
方法實(shí)現(xiàn)
- (YYTextBorder *)textBackgroundBorder {
return [self textBackgroundBorderAtIndex:0];
}
- (YYTextBorder *)textBackgroundBorderAtIndex:(NSUInteger)index {
return [self attribute:YYTextBackedStringAttributeName atIndex:index];
}
7. @property (nonatomic, readonly) CGAffineTransform textGlyphTransform; 和 - (CGAffineTransform)textGlyphTransformAtIndex:(NSUInteger)index;
獲取glyph
變換酝掩,只讀屬性,默認(rèn)值是CGAffineTransformIdentity
沒有變換眷柔。
方法實(shí)現(xiàn)
- (CGAffineTransform)textGlyphTransform {
return [self textGlyphTransformAtIndex:0];
}
- (CGAffineTransform)textGlyphTransformAtIndex:(NSUInteger)index {
NSValue *value = [self attribute:YYTextGlyphTransformAttributeName atIndex:index];
if (!value) return CGAffineTransformIdentity;
return [value CGAffineTransformValue];
}
后記
本篇主要內(nèi)容就是NSAttributedString分類的Get YYText attribute as property庸队,感興趣的給個(gè)贊或者關(guān)注~~~