版本記錄
版本號(hào) | 時(shí)間 |
---|---|
V1.0 | 2018.04.01 |
前言
iOS圈內(nèi)有幾個(gè)人大家基本都知道,比如說王巍诸典、唐巧描函,還有YYKit框架的作者現(xiàn)任職于滴滴的郭曜源 - ibireme等。這里有一篇唐巧對他的專訪狐粱,還有他的 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(四)
66. YYKit源碼探究(六十六) —— NSAttributedString分類之Get YYText attribute as property(五)
67. YYKit源碼探究(六十七) —— NSAttributedString分類之Query for YYText(六)
68. YYKit源碼探究(六十八) —— NSAttributedString分類之Create attachment string for YYText(七)
69. YYKit源碼探究(六十九) —— NSAttributedString分類之Utility(八)
70. YYKit源碼探究(七十) —— NSMutableAttributedString分類之Set character attribute(九)
71. YYKit源碼探究(七十一) —— NSMutableAttributedString分類之Set character attribute as property(十)
回顧
上一篇主要介紹了NSMutableAttributedString
分類的Set character attribute as property
部分,這一篇主要看一下NSMutableAttributedString
分類的Set paragraph attribute as property
部分蒋搜。
API
下面我們看一下API
/**
The text alignment (A wrapper for NSParagraphStyle).
@discussion Natural text alignment is realized as left or right alignment
depending on the line sweep direction of the first script contained in the paragraph.
@discussion Default is NSTextAlignmentNatural.
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readwrite) NSTextAlignment alignment;
- (void)setAlignment:(NSTextAlignment)alignment range:(NSRange)range;
/**
The mode that should be used to break lines (A wrapper for NSParagraphStyle).
@discussion This property contains the line break mode to be used laying out the paragraph's text.
@discussion Default is NSLineBreakByWordWrapping.
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readwrite) NSLineBreakMode lineBreakMode;
- (void)setLineBreakMode:(NSLineBreakMode)lineBreakMode range:(NSRange)range;
/**
The distance in points between the bottom of one line fragment and the top of the next.
(A wrapper for NSParagraphStyle)
@discussion This value is always nonnegative. This value is included in the line
fragment heights in the layout manager.
@discussion Default is 0.
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readwrite) CGFloat lineSpacing;
- (void)setLineSpacing:(CGFloat)lineSpacing range:(NSRange)range;
/**
The space after the end of the paragraph (A wrapper for NSParagraphStyle).
@discussion This property contains the space (measured in points) added at the
end of the paragraph to separate it from the following paragraph. This value must
be nonnegative. The space between paragraphs is determined by adding the previous
paragraph's paragraphSpacing and the current paragraph's paragraphSpacingBefore.
@discussion Default is 0.
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readwrite) CGFloat paragraphSpacing;
- (void)setParagraphSpacing:(CGFloat)paragraphSpacing range:(NSRange)range;
/**
The distance between the paragraph's top and the beginning of its text content.
(A wrapper for NSParagraphStyle).
@discussion This property contains the space (measured in points) between the
paragraph's top and the beginning of its text content.
@discussion Default is 0.
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readwrite) CGFloat paragraphSpacingBefore;
- (void)setParagraphSpacingBefore:(CGFloat)paragraphSpacingBefore range:(NSRange)range;
/**
The indentation of the first line (A wrapper for NSParagraphStyle).
@discussion This property contains the distance (in points) from the leading margin
of a text container to the beginning of the paragraph's first line. This value
is always nonnegative.
@discussion Default is 0.
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readwrite) CGFloat firstLineHeadIndent;
- (void)setFirstLineHeadIndent:(CGFloat)firstLineHeadIndent range:(NSRange)range;
/**
The indentation of the receiver's lines other than the first. (A wrapper for NSParagraphStyle).
@discussion This property contains the distance (in points) from the leading margin
of a text container to the beginning of lines other than the first. This value is
always nonnegative.
@discussion Default is 0.
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readwrite) CGFloat headIndent;
- (void)setHeadIndent:(CGFloat)headIndent range:(NSRange)range;
/**
The trailing indentation (A wrapper for NSParagraphStyle).
@discussion If positive, this value is the distance from the leading margin
(for example, the left margin in left-to-right text). If 0 or negative, it's the
distance from the trailing margin.
@discussion Default is 0.
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readwrite) CGFloat tailIndent;
- (void)setTailIndent:(CGFloat)tailIndent range:(NSRange)range;
/**
The receiver's minimum height (A wrapper for NSParagraphStyle).
@discussion This property contains the minimum height in points that any line in
the receiver will occupy, regardless of the font size or size of any attached graphic.
This value must be nonnegative.
@discussion Default is 0.
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readwrite) CGFloat minimumLineHeight;
- (void)setMinimumLineHeight:(CGFloat)minimumLineHeight range:(NSRange)range;
/**
The receiver's maximum line height (A wrapper for NSParagraphStyle).
@discussion This property contains the maximum height in points that any line in
the receiver will occupy, regardless of the font size or size of any attached graphic.
This value is always nonnegative. Glyphs and graphics exceeding this height will
overlap neighboring lines; however, a maximum height of 0 implies no line height limit.
Although this limit applies to the line itself, line spacing adds extra space between adjacent lines.
@discussion Default is 0 (no limit).
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readwrite) CGFloat maximumLineHeight;
- (void)setMaximumLineHeight:(CGFloat)maximumLineHeight range:(NSRange)range;
/**
The line height multiple (A wrapper for NSParagraphStyle).
@discussion This property contains the line break mode to be used laying out the paragraph's text.
@discussion Default is 0 (no multiple).
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readwrite) CGFloat lineHeightMultiple;
- (void)setLineHeightMultiple:(CGFloat)lineHeightMultiple range:(NSRange)range;
/**
The base writing direction (A wrapper for NSParagraphStyle).
@discussion If you specify NSWritingDirectionNaturalDirection, the receiver resolves
the writing direction to either NSWritingDirectionLeftToRight or NSWritingDirectionRightToLeft,
depending on the direction for the user's `language` preference setting.
@discussion Default is NSWritingDirectionNatural.
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readwrite) NSWritingDirection baseWritingDirection;
- (void)setBaseWritingDirection:(NSWritingDirection)baseWritingDirection range:(NSRange)range;
/**
The paragraph's threshold for hyphenation. (A wrapper for NSParagraphStyle).
@discussion Valid values lie between 0.0 and 1.0 inclusive. Hyphenation is attempted
when the ratio of the text width (as broken without hyphenation) to the width of the
line fragment is less than the hyphenation factor. When the paragraph's hyphenation
factor is 0.0, the layout manager's hyphenation factor is used instead. When both
are 0.0, hyphenation is disabled.
@discussion Default is 0.
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since UIKit:6.0
*/
@property (nonatomic, readwrite) float hyphenationFactor;
- (void)setHyphenationFactor:(float)hyphenationFactor range:(NSRange)range;
/**
The document-wide default tab interval (A wrapper for NSParagraphStyle).
@discussion This property represents the default tab interval in points. Tabs after the
last specified in tabStops are placed at integer multiples of this distance (if positive).
@discussion Default is 0.
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:7.0 UIKit:7.0 YYKit:7.0
*/
@property (nonatomic, readwrite) CGFloat defaultTabInterval;
- (void)setDefaultTabInterval:(CGFloat)defaultTabInterval range:(NSRange)range NS_AVAILABLE_IOS(7_0);
/**
An array of NSTextTab objects representing the receiver's tab stops.
(A wrapper for NSParagraphStyle).
@discussion The NSTextTab objects, sorted by location, define the tab stops for
the paragraph style.
@discussion Default is 12 TabStops with 28.0 tab interval.
@discussion Set this property applies to the entire text string.
Get this property returns the first character's attribute.
@since CoreText:7.0 UIKit:7.0 YYKit:7.0
*/
@property (nullable, nonatomic, copy, readwrite) NSArray<NSTextTab *> *tabStops;
- (void)setTabStops:(nullable NSArray<NSTextTab *> *)tabStops range:(NSRange)range NS_AVAILABLE_IOS(7_0);
下面我們就一起詳細(xì)的看一下篡撵。
1. @property (nonatomic, readwrite) NSTextAlignment alignment; 和 - (void)setAlignment:(NSTextAlignment)alignment range:(NSRange)range;
文本對齊方式判莉,NSParagraphStyle
的封裝,默認(rèn)值是NSTextAlignmentNatural
育谬。
Natural
文本對齊根據(jù)段落中包含的第一個(gè)腳本的行掃描方向?qū)崿F(xiàn)為左或右對齊券盅。
方法實(shí)現(xiàn)
- (void)setAlignment:(NSTextAlignment)alignment {
[self setAlignment:alignment range:NSMakeRange(0, self.length)];
}
- (void)setAlignment:(NSTextAlignment)alignment range:(NSRange)range {
ParagraphStyleSet(alignment);
}
#define ParagraphStyleSet(_attr_) \
[self enumerateAttribute:NSParagraphStyleAttributeName \
inRange:range \
options:kNilOptions \
usingBlock: ^(NSParagraphStyle *value, NSRange subRange, BOOL *stop) { \
NSMutableParagraphStyle *style = nil; \
if (value) { \
if (CFGetTypeID((__bridge CFTypeRef)(value)) == CTParagraphStyleGetTypeID()) { \
value = [NSParagraphStyle styleWithCTStyle:(__bridge CTParagraphStyleRef)(value)]; \
} \
if (value. _attr_ == _attr_) return; \
if ([value isKindOfClass:[NSMutableParagraphStyle class]]) { \
style = (id)value; \
} else { \
style = value.mutableCopy; \
} \
} else { \
if ([NSParagraphStyle defaultParagraphStyle]. _attr_ == _attr_) return; \
style = [NSParagraphStyle defaultParagraphStyle].mutableCopy; \
} \
style. _attr_ = _attr_; \
[self setParagraphStyle:style range:subRange]; \
}];
2. @property (nonatomic, readwrite) NSLineBreakMode lineBreakMode; 和 - (void)setLineBreakMode:(NSLineBreakMode)lineBreakMode range:(NSRange)range;
換行模式,默認(rèn)值是NSLineBreakByWordWrapping
膛檀。該屬性包含用于布置段落文本的換行符模式锰镀。
方法實(shí)現(xiàn)
- (void)setLineBreakMode:(NSLineBreakMode)lineBreakMode {
[self setLineBreakMode:lineBreakMode range:NSMakeRange(0, self.length)];
}
- (void)setLineBreakMode:(NSLineBreakMode)lineBreakMode range:(NSRange)range {
ParagraphStyleSet(lineBreakMode);
}
3. @property (nonatomic, readwrite) CGFloat lineSpacing; 和 - (void)setLineSpacing:(CGFloat)lineSpacing range:(NSRange)range;
一個(gè)線段底部與下一個(gè)線段頂部之間的距離(以點(diǎn)為單位)。這個(gè)值總是非負(fù)的宿刮,這個(gè)值包含在布局管理器中的行高里面互站。
方法實(shí)現(xiàn)
- (void)setLineSpacing:(CGFloat)lineSpacing {
[self setLineSpacing:lineSpacing range:NSMakeRange(0, self.length)];
}
- (void)setLineSpacing:(CGFloat)lineSpacing range:(NSRange)range {
ParagraphStyleSet(lineSpacing);
}
4. @property (nonatomic, readwrite) CGFloat paragraphSpacing; 和 - (void)setParagraphSpacing:(CGFloat)paragraphSpacing range:(NSRange)range;
段落結(jié)束后的空間。
該屬性包含段落末尾添加的空間(以點(diǎn)為單位)僵缺,以將其與以下段落分開胡桃。 這個(gè)值必須是非負(fù)的。 段落之間的空間通過前一段的段落paragraphSpacing
和當(dāng)前段落的段落paragraphSpacingBefore
的加和來確定磕潮,缺省值是0翠胰。
方法實(shí)現(xiàn)
- (void)setParagraphSpacing:(CGFloat)paragraphSpacing {
[self setParagraphSpacing:paragraphSpacing range:NSMakeRange(0, self.length)];
}
- (void)setParagraphSpacing:(CGFloat)paragraphSpacing range:(NSRange)range {
ParagraphStyleSet(paragraphSpacing);
}
5. @property (nonatomic, readwrite) CGFloat paragraphSpacingBefore; 和 - (void)setParagraphSpacingBefore:(CGFloat)paragraphSpacingBefore range:(NSRange)range;
段落頂部與其文本內(nèi)容開始之間的距離。
方法實(shí)現(xiàn)
- (void)setParagraphSpacingBefore:(CGFloat)paragraphSpacingBefore {
[self setParagraphSpacing:paragraphSpacingBefore range:NSMakeRange(0, self.length)];
}
- (void)setParagraphSpacingBefore:(CGFloat)paragraphSpacingBefore range:(NSRange)range {
ParagraphStyleSet(paragraphSpacingBefore);
}
6. @property (nonatomic, readwrite) CGFloat firstLineHeadIndent; 和 - (void)setFirstLineHeadIndent:(CGFloat)firstLineHeadIndent range:(NSRange)range;
第一行的縮進(jìn)自脯,默認(rèn)值為0之景。
此屬性包含從文本容器的前導(dǎo)邊距到段落第一行開頭的距離(以點(diǎn)為單位)。 這個(gè)值總是非負(fù)的膏潮。
方法實(shí)現(xiàn)
- (void)setFirstLineHeadIndent:(CGFloat)firstLineHeadIndent {
[self setFirstLineHeadIndent:firstLineHeadIndent range:NSMakeRange(0, self.length)];
}
- (void)setFirstLineHeadIndent:(CGFloat)firstLineHeadIndent range:(NSRange)range {
ParagraphStyleSet(firstLineHeadIndent);
}
7. @property (nonatomic, readwrite) CGFloat headIndent; 和 - (void)setHeadIndent:(CGFloat)headIndent range:(NSRange)range;
除第一個(gè)以外的receiver行的縮進(jìn)锻狗,默認(rèn)值是0。
該屬性包含從文本容器的前導(dǎo)邊距到除第一個(gè)行之外的行的起始位置的距離(以點(diǎn)為單位)焕参。 這個(gè)值總是非負(fù)的轻纪。
方法實(shí)現(xiàn)
- (void)setHeadIndent:(CGFloat)headIndent {
[self setHeadIndent:headIndent range:NSMakeRange(0, self.length)];
}
- (void)setHeadIndent:(CGFloat)headIndent range:(NSRange)range {
ParagraphStyleSet(headIndent);
}
8. @property (nonatomic, readwrite) CGFloat tailIndent; 和 - (void)setTailIndent:(CGFloat)tailIndent range:(NSRange)range;
尾部縮進(jìn),默認(rèn)值為0叠纷。
如果為正數(shù)库倘,則此值為距前邊距的距離(例如济舆,從左到右的文本中的左邊距)巷屿。 如果為0或負(fù)值省核,則表示距尾端距離。
方法實(shí)現(xiàn)
- (void)setTailIndent:(CGFloat)tailIndent {
[self setTailIndent:tailIndent range:NSMakeRange(0, self.length)];
}
- (void)setTailIndent:(CGFloat)tailIndent range:(NSRange)range {
ParagraphStyleSet(tailIndent);
}
9. @property (nonatomic, readwrite) CGFloat minimumLineHeight; 和 - (void)setMinimumLineHeight:(CGFloat)minimumLineHeight range:(NSRange)range;
最小行高航厚。
無論任何附加圖形的字體大小或大小顷歌,此屬性都包含receiver中任何行將占用的最小高度,以點(diǎn)進(jìn)行計(jì)算幔睬。 這個(gè)值必須是非負(fù)的眯漩。
方法實(shí)現(xiàn)
- (void)setMinimumLineHeight:(CGFloat)minimumLineHeight {
[self setMinimumLineHeight:minimumLineHeight range:NSMakeRange(0, self.length)];
}
- (void)setMinimumLineHeight:(CGFloat)minimumLineHeight range:(NSRange)range {
ParagraphStyleSet(minimumLineHeight);
}
10. @property (nonatomic, readwrite) CGFloat maximumLineHeight; 和 - (void)setMaximumLineHeight:(CGFloat)maximumLineHeight range:(NSRange)range;
receiver最大行高,默認(rèn)值為0溪窒。
無論任何附加圖形的字體大小或大小坤塞,此屬性都包含receiver中任何行將占用的最大高度,以點(diǎn)進(jìn)行計(jì)算澈蚌。 這個(gè)值總是非負(fù)的摹芙。 超過此高度的字形和圖形將與相鄰行重疊;然而宛瞄,最大高度為0意味著沒有行高度限制浮禾。 雖然此限制適用于行本身,但行間距會(huì)在相鄰行之間增加額外的空間份汗。
方法實(shí)現(xiàn)
- (void)setMaximumLineHeight:(CGFloat)maximumLineHeight {
[self setMaximumLineHeight:maximumLineHeight range:NSMakeRange(0, self.length)];
}
- (void)setMaximumLineHeight:(CGFloat)maximumLineHeight range:(NSRange)range {
ParagraphStyleSet(maximumLineHeight);
}
11. @property (nonatomic, readwrite) CGFloat lineHeightMultiple; 和 - (void)setLineHeightMultiple:(CGFloat)lineHeightMultiple range:(NSRange)range;
行高倍數(shù)盈电,默認(rèn)值為0。
該屬性包含用于布置段落文本的換行符模式杯活。
方法實(shí)現(xiàn)
- (void)setLineHeightMultiple:(CGFloat)lineHeightMultiple {
[self setLineHeightMultiple:lineHeightMultiple range:NSMakeRange(0, self.length)];
}
- (void)setLineHeightMultiple:(CGFloat)lineHeightMultiple range:(NSRange)range {
ParagraphStyleSet(lineHeightMultiple);
}
12. @property (nonatomic, readwrite) NSWritingDirection baseWritingDirection; 和 - (void)setBaseWritingDirection:(NSWritingDirection)baseWritingDirection range:(NSRange)range;
The base writing direction
匆帚,默認(rèn)值是NSWritingDirectionNatural
。
如果指定了NSWritingDirectionNaturalDirection
旁钧,則receiver
根據(jù)用戶的language
偏好設(shè)置的方向吸重,將寫入方向解析為NSWritingDirectionLeftToRight
或NSWritingDirectionRightToLeft
。
方法實(shí)現(xiàn)
- (void)setBaseWritingDirection:(NSWritingDirection)baseWritingDirection {
[self setBaseWritingDirection:baseWritingDirection range:NSMakeRange(0, self.length)];
}
- (void)setBaseWritingDirection:(NSWritingDirection)baseWritingDirection range:(NSRange)range {
ParagraphStyleSet(baseWritingDirection);
}
13. @property (nonatomic, readwrite) float hyphenationFactor; 和 - (void)setHyphenationFactor:(float)hyphenationFactor range:(NSRange)range;
段落的hyphenation
閾值歪今,默認(rèn)值為0嚎幸。
有效值介于0.0和1.0之間。 如果文本寬度(如果沒有連字符斷開)與行寬度的比率小于Hyphenation
因子寄猩,則嘗試進(jìn)行Hyphenation
嫉晶。 當(dāng)段落的hyphenation
因子為0.0時(shí),將使用布局管理器的hyphenation因子田篇。 當(dāng)兩者均為0.0時(shí)替废,hyphenation被禁用。
方法實(shí)現(xiàn)
- (void)setHyphenationFactor:(float)hyphenationFactor {
[self setHyphenationFactor:hyphenationFactor range:NSMakeRange(0, self.length)];
}
- (void)setHyphenationFactor:(float)hyphenationFactor range:(NSRange)range {
ParagraphStyleSet(hyphenationFactor);
}
14. @property (nonatomic, readwrite) CGFloat defaultTabInterval; 和 - (void)setDefaultTabInterval:(CGFloat)defaultTabInterval range:(NSRange)range NS_AVAILABLE_IOS(7_0);
文檔范圍的默認(rèn)tab間隔斯辰,默認(rèn)值為0舶担。
該屬性表示默認(rèn)的tab間隔(以點(diǎn)為單位)。 tabStops中指定的最后tabs位于此距離的整數(shù)倍(如果為正數(shù))彬呻。
方法實(shí)現(xiàn)
- (void)setDefaultTabInterval:(CGFloat)defaultTabInterval {
[self setDefaultTabInterval:defaultTabInterval range:NSMakeRange(0, self.length)];
}
- (void)setDefaultTabInterval:(CGFloat)defaultTabInterval range:(NSRange)range {
if (!kiOS7Later) return;
ParagraphStyleSet(defaultTabInterval);
}
15. @property (nullable, nonatomic, copy, readwrite) NSArray<NSTextTab *> *tabStops; 和 - (void)setTabStops:(nullable NSArray<NSTextTab *> *)tabStops range:(NSRange)range NS_AVAILABLE_IOS(7_0);
一個(gè)NSTextTab
數(shù)組衣陶,代表receiver
的tab stops
。默認(rèn)值是12 TabStops
闸氮,帶有28.0 tab
間隔剪况。
按位置排序的NSTextTab
對象為段落樣式定義了tab stops
。
方法實(shí)現(xiàn)
- (void)setTabStops:(NSArray *)tabStops {
[self setTabStops:tabStops range:NSMakeRange(0, self.length)];
}
- (void)setTabStops:(NSArray *)tabStops range:(NSRange)range {
if (!kiOS7Later) return;
ParagraphStyleSet(tabStops);
}
后記
本篇主要介紹了NSMutableAttributedString分類的Set paragraph attribute as property蒲跨,感興趣的可以給個(gè)贊和關(guān)注~~~~