版本記錄
版本號(hào) | 時(shí)間 |
---|---|
V1.0 | 2018.03.31 |
前言
iOS圈內(nèi)有幾個(gè)人大家基本都知道龄砰,比如說(shuō)王巍钳榨、唐巧,還有YYKit框架的作者現(xiàn)任職于滴滴的郭曜源 - ibireme等榨馁。這里有一篇唐巧對(duì)他的專(zhuān)訪,還有他的 GitHub - Yaoyuan 和 博客帜矾,這里貼出來(lái)框架YYKit 框架翼虫。接下來(lái)幾篇我們就一起來(lái)看一下這個(gè)框架。感興趣的可以看上面寫(xiě)的幾篇屡萤。
1. YYKit源碼探究(一) —— 基本概覽
2. YYKit源碼探究(二) —— NSString分類(lèi)之Hash(一)
3. YYKit源碼探究(三) —— NSString分類(lèi)之Encode and decode(二)
4. YYKit源碼探究(四) —— NSString分類(lèi)之Drawing(三)
5. YYKit源碼探究(五) —— NSString分類(lèi)之Regular Expression(四)
6. YYKit源碼探究(六) —— NSString分類(lèi)之NSNumber Compatible(五)
7. YYKit源碼探究(七) —— NSString分類(lèi)之Utilities(六)
8. YYKit源碼探究(八) —— NSNumber分類(lèi)(一)
9. YYKit源碼探究(九) —— UIFont分類(lèi)之架構(gòu)分析和Font Traits(一)
10. YYKit源碼探究(十) —— UIFont分類(lèi)之Create font(二)
11. YYKit源碼探究(十一) —— UIFont分類(lèi)之Load and unload font(三)
12. YYKit源碼探究(十二) —— UIFont分類(lèi)之Dump font data(四)
13. YYKit源碼探究(十三) —— UIImage分類(lèi)之框架結(jié)構(gòu)和Create image部分(一)
14. YYKit源碼探究(十四) —— UIImage分類(lèi)之Image Info(二)
15. YYKit源碼探究(十五) —— UIImage分類(lèi)之Modify Image(三)
16. YYKit源碼探究(十六) —— UIImage分類(lèi)之Image Effect(四)
17. YYKit源碼探究(十七) —— UIImageView分類(lèi)之架構(gòu)和image部分(一)
18. YYKit源碼探究(十八) —— UIImageView分類(lèi)之highlight image部分(二)
19. YYKit源碼探究(十九) —— UIScreen分類(lèi)(一)
20. YYKit源碼探究(二十) —— UIScrollView分類(lèi)(一)
21. YYKit源碼探究(二十一) —— UITableView分類(lèi)(一)
22. YYKit源碼探究(二十二) —— UITextField分類(lèi)(一)
23. YYKit源碼探究(二十三) —— UIView分類(lèi)(一)
24. YYKit源碼探究(二十四) —— UIPasteboard分類(lèi)(一)
25. YYKit源碼探究(二十五) —— UIGestureRecognizer分類(lèi)(一)
26. YYKit源碼探究(二十六) —— UIDevice分類(lèi)框架及Device Information(一)
27. YYKit源碼探究(二十七) —— UIDevice分類(lèi)之Network Information(二)
28. YYKit源碼探究(二十八) —— UIDevice分類(lèi)之Disk Space(三)
29. YYKit源碼探究(二十九) —— UIDevice分類(lèi)之Memory Information(四)
30. YYKit源碼探究(三十) —— UIDevice分類(lèi)之CPU Information(五)
31. YYKit源碼探究(三十一) —— UIControl分類(lèi)(一)
32. YYKit源碼探究(三十二) —— UIColor分類(lèi)之Create a UIColor Object(一)
33. YYKit源碼探究(三十三) —— UIColor分類(lèi)之Get color's description(二)
34. YYKit源碼探究(三十四) —— UIColor分類(lèi)之Retrieving Color Information(三)
35. YYKit源碼探究(三十五) —— UIButton分類(lèi)之image(一)
36. YYKit源碼探究(三十六) —— UIButton分類(lèi)之background image(二)
37. YYKit源碼探究(三十七) —— UIBezierPath分類(lèi)(一)
38. YYKit源碼探究(三十八) —— UIBarButtonItem分類(lèi)(一)
39. YYKit源碼探究(三十九) —— UIApplication分類(lèi)(一)
40. YYKit源碼探究(四十) —— NSTimer分類(lèi)(一)
41. YYKit源碼探究(四十一) —— NSParagraphStyle分類(lèi)(一)
42. YYKit源碼探究(四十二) —— NSObject分類(lèi)之YYModel(一)
43. YYKit源碼探究(四十三) —— NSObject分類(lèi)之KVO(二)
44. YYKit源碼探究(四十四) —— NSObject分類(lèi)之Sending messages with variable parameters(三)
45. YYKit源碼探究(四十五) —— NSObject分類(lèi)之Swap method (Swizzling)(四)
46. YYKit源碼探究(四十六) —— NSObject分類(lèi)之Associate value(五)
47. YYKit源碼探究(四十七) —— NSObject分類(lèi)之Other(六)
48. YYKit源碼探究(四十八) —— NSNotificationCenter分類(lèi)(一)
49. YYKit源碼探究(四十九) —— NSKeyedUnarchiver分類(lèi)(一)
50. YYKit源碼探究(五十) —— NSDictionary分類(lèi)之Dictionary Convertor(一)
51. YYKit源碼探究(五十一) —— NSDictionary分類(lèi)之Dictionary Value Getter(二)
52. YYKit源碼探究(五十二) —— NSDictionary分類(lèi)之NSMutableDictionary(三)
53. YYKit源碼探究(五十三) —— NSDate分類(lèi)之Component Properties(一)
54. YYKit源碼探究(五十四) —— NSDate分類(lèi)之Date modify(二)
55. YYKit源碼探究(五十五) —— NSDate分類(lèi)之Date Format(三)
56. YYKit源碼探究(五十六) —— NSData分類(lèi)之Hash(一)
57. YYKit源碼探究(五十七) —— NSData分類(lèi)之Encrypt and Decrypt(二)
58. YYKit源碼探究(五十八) —— NSData分類(lèi)之Encode and decode(三)
59. YYKit源碼探究(五十九) —— NSData分類(lèi)之Inflate and deflate(四)
60. YYKit源碼探究(六十) —— NSData分類(lèi)之Others(五)
61. YYKit源碼探究(六十一) —— NSBundle分類(lèi)(一)
62. YYKit源碼探究(六十二) —— NSAttributedString分類(lèi)之基本(一)
63. YYKit源碼探究(六十三) —— NSAttributedString分類(lèi)之Retrieving character attribute information(二)
64. YYKit源碼探究(六十四) —— NSAttributedString分類(lèi)之Get character attribute as property(三)
回顧
上一篇主要介紹了NSAttributedString
分類(lèi)的Get character attribute as property
部分珍剑,這一篇主要看一下NSAttributedString
分類(lèi)的Get paragraph attribute as property
部分。
API
下面我們看一下API
/**
The text alignment (A wrapper for NSParagraphStyle). (read-only)
@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 Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readonly) NSTextAlignment alignment;
- (NSTextAlignment)alignmentAtIndex:(NSUInteger)index;
/**
The mode that should be used to break lines (A wrapper for NSParagraphStyle). (read-only)
@discussion This property contains the line break mode to be used laying out the paragraph's text.
@discussion Default is NSLineBreakByWordWrapping.
@discussion Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readonly) NSLineBreakMode lineBreakMode;
- (NSLineBreakMode)lineBreakModeAtIndex:(NSUInteger)index;
/**
The distance in points between the bottom of one line fragment and the top of the next.
(A wrapper for NSParagraphStyle) (read-only)
@discussion This value is always nonnegative. This value is included in the line
fragment heights in the layout manager.
@discussion Default is 0.
@discussion Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readonly) CGFloat lineSpacing;
- (CGFloat)lineSpacingAtIndex:(NSUInteger)index;
/**
The space after the end of the paragraph (A wrapper for NSParagraphStyle). (read-only)
@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 Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readonly) CGFloat paragraphSpacing;
- (CGFloat)paragraphSpacingAtIndex:(NSUInteger)index;
/**
The distance between the paragraph's top and the beginning of its text content.
(A wrapper for NSParagraphStyle). (read-only)
@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 Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readonly) CGFloat paragraphSpacingBefore;
- (CGFloat)paragraphSpacingBeforeAtIndex:(NSUInteger)index;
/**
The indentation of the first line (A wrapper for NSParagraphStyle). (read-only)
@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 Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readonly) CGFloat firstLineHeadIndent;
- (CGFloat)firstLineHeadIndentAtIndex:(NSUInteger)index;
/**
The indentation of the receiver's lines other than the first. (A wrapper for NSParagraphStyle). (read-only)
@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 Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readonly) CGFloat headIndent;
- (CGFloat)headIndentAtIndex:(NSUInteger)index;
/**
The trailing indentation (A wrapper for NSParagraphStyle). (read-only)
@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 Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readonly) CGFloat tailIndent;
- (CGFloat)tailIndentAtIndex:(NSUInteger)index;
/**
The receiver's minimum height (A wrapper for NSParagraphStyle). (read-only)
@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 Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readonly) CGFloat minimumLineHeight;
- (CGFloat)minimumLineHeightAtIndex:(NSUInteger)index;
/**
The receiver's maximum line height (A wrapper for NSParagraphStyle). (read-only)
@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 Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readonly) CGFloat maximumLineHeight;
- (CGFloat)maximumLineHeightAtIndex:(NSUInteger)index;
/**
The line height multiple (A wrapper for NSParagraphStyle). (read-only)
@discussion This property contains the line break mode to be used laying out the paragraph's text.
@discussion Default is 0 (no multiple).
@discussion Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readonly) CGFloat lineHeightMultiple;
- (CGFloat)lineHeightMultipleAtIndex:(NSUInteger)index;
/**
The base writing direction (A wrapper for NSParagraphStyle). (read-only)
@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 Get this property returns the first character's attribute.
@since CoreText:6.0 UIKit:6.0 YYKit:6.0
*/
@property (nonatomic, readonly) NSWritingDirection baseWritingDirection;
- (NSWritingDirection)baseWritingDirectionAtIndex:(NSUInteger)index;
/**
The paragraph's threshold for hyphenation. (A wrapper for NSParagraphStyle). (read-only)
@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 Get this property returns the first character's attribute.
@since UIKit:6.0
*/
@property (nonatomic, readonly) float hyphenationFactor;
- (float)hyphenationFactorAtIndex:(NSUInteger)index;
/**
The document-wide default tab interval (A wrapper for NSParagraphStyle). (read-only)
@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 Get this property returns the first character's attribute.
@since CoreText:7.0 UIKit:7.0 YYKit:7.0
*/
@property (nonatomic, readonly) CGFloat defaultTabInterval;
- (CGFloat)defaultTabIntervalAtIndex:(NSUInteger)index;
/**
An array of NSTextTab objects representing the receiver's tab stops.
(A wrapper for NSParagraphStyle). (read-only)
@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 Get this property returns the first character's attribute.
@since CoreText:7.0 UIKit:7.0 YYKit:7.0
*/
@property (nullable, nonatomic, copy, readonly) NSArray<NSTextTab *> *tabStops;
- (nullable NSArray<NSTextTab *> *)tabStopsAtIndex:(NSUInteger)index;
下面我們?cè)敿?xì)的看一下死陆。
1. @property (nonatomic, readonly) NSTextAlignment alignment; 和 - (NSTextAlignment)alignmentAtIndex:(NSUInteger)index;
該屬性的作用就是文本對(duì)齊方式招拙。(A wrapper for NSParagraphStyle)
。
根據(jù)段落中包含的第一個(gè)腳本的行掃描方向措译,文本對(duì)齊被實(shí)現(xiàn)為左對(duì)齊或右對(duì)齊别凤。默認(rèn)的對(duì)齊方式是NSTextAlignmentNatural
。
方法實(shí)現(xiàn)
- (NSTextAlignment)alignment {
ParagraphAttribute(alignment);
}
#define ParagraphAttribute(_attr_) \
NSParagraphStyle *style = self.paragraphStyle; \
if (!style) style = [NSParagraphStyle defaultParagraphStyle]; \
return style. _attr_;
- (NSTextAlignment)alignmentAtIndex:(NSUInteger)index {
ParagraphAttributeAtIndex(alignment);
}
#define ParagraphAttributeAtIndex(_attr_) \
NSParagraphStyle *style = [self paragraphStyleAtIndex:index]; \
if (!style) style = [NSParagraphStyle defaultParagraphStyle]; \
return style. _attr_;
2. @property (nonatomic, readonly) NSLineBreakMode lineBreakMode; 和 - (NSLineBreakMode)lineBreakModeAtIndex:(NSUInteger)index;
應(yīng)該用于分行的模式(NSParagraphStyle
的包裝)领虹。 (只讀)规哪,該屬性包含用于布置段落文本的換行符模式,默認(rèn)是NSLineBreakByWordWrapping
掠械。
方法實(shí)現(xiàn)
- (NSLineBreakMode)lineBreakMode {
ParagraphAttribute(lineBreakMode);
}
- (NSLineBreakMode)lineBreakModeAtIndex:(NSUInteger)index {
ParagraphAttributeAtIndex(lineBreakMode);
}
3. @property (nonatomic, readonly) CGFloat lineSpacing; 和 - (CGFloat)lineSpacingAtIndex:(NSUInteger)index;
該組的作用獲取就是一個(gè)線段底部與下一個(gè)線段頂部之間的距離由缆。該值永遠(yuǎn)是非負(fù)的,該值包含在布局管理器中的線段高度中猾蒂。
方法實(shí)現(xiàn)
- (CGFloat)lineSpacing {
ParagraphAttribute(lineSpacing);
}
- (CGFloat)lineSpacingAtIndex:(NSUInteger)index {
ParagraphAttributeAtIndex(lineSpacing);
}
4. @property (nonatomic, readonly) CGFloat paragraphSpacing; 和 - (CGFloat)paragraphSpacingAtIndex:(NSUInteger)index;
段落結(jié)束后的空格(NSParagraphStyle
的包裝)均唉,只讀。
該屬性包含段落末尾添加的空間(以點(diǎn)為單位)肚菠,以將其與以下段落分開(kāi)舔箭。 這個(gè)值必須是非負(fù)的。 段落之間的空間通過(guò)添加前一段的段落空間和當(dāng)前段落的段落空間來(lái)確定。默認(rèn)值為0层扶。
方法實(shí)現(xiàn)
- (CGFloat)paragraphSpacing {
ParagraphAttribute(paragraphSpacing);
}
- (CGFloat)paragraphSpacingAtIndex:(NSUInteger)index {
ParagraphAttributeAtIndex(paragraphSpacing);
}
5. @property (nonatomic, readonly) CGFloat paragraphSpacingBefore; 和 - (CGFloat)paragraphSpacingBeforeAtIndex:(NSUInteger)index;
段落頂部與其文本內(nèi)容開(kāi)始之間的距離箫章,(NSParagraphStyle
的包裝器),只讀镜会。此屬性包含段落頂部與其文本內(nèi)容開(kāi)頭之間的空間(以點(diǎn)為單位)檬寂,默認(rèn)值為0。
方法實(shí)現(xiàn)
- (CGFloat)paragraphSpacingBefore {
ParagraphAttribute(paragraphSpacingBefore);
}
- (CGFloat)paragraphSpacingBeforeAtIndex:(NSUInteger)index {
ParagraphAttributeAtIndex(paragraphSpacingBefore);
}
6. @property (nonatomic, readonly) CGFloat firstLineHeadIndent; 和 - (CGFloat)firstLineHeadIndentAtIndex:(NSUInteger)index;
第一行的縮進(jìn)(NSParagraphStyle
的包裝)戳表, (只讀)桶至。此屬性包含從文本容器的前導(dǎo)邊距到段落第一行開(kāi)頭的距離(以點(diǎn)為單位),這個(gè)值總是非負(fù)的匾旭,默認(rèn)值為0镣屹。
方法實(shí)現(xiàn)
- (CGFloat)firstLineHeadIndent {
ParagraphAttribute(firstLineHeadIndent);
}
- (CGFloat)firstLineHeadIndentAtIndex:(NSUInteger)index {
ParagraphAttributeAtIndex(firstLineHeadIndent);
}
7. @property (nonatomic, readonly) CGFloat headIndent; 和 - (CGFloat)headIndentAtIndex:(NSUInteger)index;
除第一個(gè)以外的receiver行的縮進(jìn),(NSParagraphStyle
的包裝器)价涝,(只讀)女蜈。該屬性包含從文本容器的前導(dǎo)邊距到除第一個(gè)行之外的行的起始位置的距離(以點(diǎn)為單位),這個(gè)值總是非負(fù)的色瘩。默認(rèn)值為0伪窖。
方法實(shí)現(xiàn)
- (CGFloat)headIndent {
ParagraphAttribute(headIndent);
}
- (CGFloat)headIndentAtIndex:(NSUInteger)index {
ParagraphAttributeAtIndex(headIndent);
}
8. @property (nonatomic, readonly) CGFloat tailIndent; 和 - (CGFloat)tailIndentAtIndex:(NSUInteger)index;
尾部縮進(jìn)(NSParagraphStyle
的包裝),(只讀)泞遗。如果為正數(shù)惰许,則此值為距前邊距的距離(例如席覆,從左到右文本中的左邊距)史辙。 如果為0或負(fù)值,則表示距尾端距離佩伤。默認(rèn)值為0聊倔。
方法實(shí)現(xiàn)
- (CGFloat)tailIndent {
ParagraphAttribute(tailIndent);
}
- (CGFloat)tailIndentAtIndex:(NSUInteger)index {
ParagraphAttributeAtIndex(tailIndent);
}
9. @property (nonatomic, readonly) CGFloat minimumLineHeight; 和 - (CGFloat)minimumLineHeightAtIndex:(NSUInteger)index;
receiver的最小高度,NSParagraphStyle
的封裝生巡,只讀屬性耙蔑。無(wú)論任何附加圖形的字體大小或大小,此屬性都包含接收器中任何行將占用的點(diǎn)數(shù)的最小高度孤荣。 這個(gè)值必須是非負(fù)的甸陌,默認(rèn)值為0。
方法實(shí)現(xiàn)
- (CGFloat)minimumLineHeight {
ParagraphAttribute(minimumLineHeight);
}
- (CGFloat)minimumLineHeightAtIndex:(NSUInteger)index {
ParagraphAttributeAtIndex(minimumLineHeight);
}
10. @property (nonatomic, readonly) CGFloat maximumLineHeight; 和 - (CGFloat)maximumLineHeightAtIndex:(NSUInteger)index;
該組的作用就是receiver最大行高盐股,NSParagraphStyle
的封裝钱豁,只讀的。
無(wú)論任何附加圖形的字體大小或大小如何疯汁,該屬性都包含接收器中任何行將占用的最大點(diǎn)數(shù)牲尺。 這個(gè)值總是非負(fù)的。 超過(guò)此高度的字形和圖形將與相鄰行重疊;然而谤碳,最大高度為0意味著沒(méi)有線高度限制溃卡。 雖然此限制適用于行本身,但行間距會(huì)在相鄰行之間增加額外的空間蜒简。
方法實(shí)現(xiàn)
- (CGFloat)maximumLineHeight {
ParagraphAttribute(maximumLineHeight);
}
- (CGFloat)maximumLineHeightAtIndex:(NSUInteger)index {
ParagraphAttributeAtIndex(maximumLineHeight);
}
11. @property (nonatomic, readonly) CGFloat lineHeightMultiple; 和 - (CGFloat)lineHeightMultipleAtIndex:(NSUInteger)index;
該組是獲取行高倍數(shù)瘸羡,NSParagraphStyle
的封裝,只讀屬性搓茬。默認(rèn)值是0最铁。
該屬性包含用于布置段落文本的換行符模式。
方法實(shí)現(xiàn)
- (CGFloat)lineHeightMultiple {
ParagraphAttribute(lineHeightMultiple);
}
- (CGFloat)lineHeightMultipleAtIndex:(NSUInteger)index {
ParagraphAttributeAtIndex(lineHeightMultiple);
}
12. @property (nonatomic, readonly) NSWritingDirection baseWritingDirection; 和 - (NSWritingDirection)baseWritingDirectionAtIndex:(NSUInteger)index;
該組的作用就是基本書(shū)寫(xiě)方向垮兑,NSParagraphStyle
的封裝冷尉,只讀屬性。默認(rèn)值是NSWritingDirectionNatural
系枪。
如果指定NSWritingDirectionNaturalDirection
雀哨,則接收方將寫(xiě)入方向解析為NSWritingDirectionLeftToRight
或NSWritingDirectionRightToLeft
,具體取決于用戶language
偏好設(shè)置的方向私爷。
方法實(shí)現(xiàn)
- (NSWritingDirection)baseWritingDirection {
ParagraphAttribute(baseWritingDirection);
}
- (NSWritingDirection)baseWritingDirectionAtIndex:(NSUInteger)index {
ParagraphAttributeAtIndex(baseWritingDirection);
}
13. @property (nonatomic, readonly) float hyphenationFactor; 和 - (float)hyphenationFactorAtIndex:(NSUInteger)index;
該組獲取該段落的hyphenation
閾值雾棺,默認(rèn)值為0,只讀屬性衬浑,NSParagraphStyle
的封裝捌浩。
有效值介于0.0和1.0之間。 當(dāng)文本寬度(如果沒(méi)有連字符斷開(kāi))與行寬度的比率小于hyphenation
因子工秩,則嘗試進(jìn)行連字尸饺。 當(dāng)段落的連字因子為0.0時(shí),將使用布局管理器的連字因子助币。 當(dāng)兩者均為0.0時(shí)浪听,連字符被禁用。
方法實(shí)現(xiàn)
- (float)hyphenationFactor {
ParagraphAttribute(hyphenationFactor);
}
- (float)hyphenationFactorAtIndex:(NSUInteger)index {
ParagraphAttributeAtIndex(hyphenationFactor);
}
14. @property (nonatomic, readonly) CGFloat defaultTabInterval; 和 - (CGFloat)defaultTabIntervalAtIndex:(NSUInteger)index;
該組獲取文檔寬度的默認(rèn)tab間隔眉菱,NSParagraphStyle的封裝迹栓,只讀屬性,默認(rèn)值為0俭缓。
該屬性表示默認(rèn)的tab間隔(以點(diǎn)為單位)克伊。 tabStops中指定的最后一個(gè)tab位于此距離的整數(shù)倍(如果為正數(shù))。
方法實(shí)現(xiàn)
- (CGFloat)defaultTabInterval {
if (!kiOS7Later) return 0;
ParagraphAttribute(defaultTabInterval);
}
- (CGFloat)defaultTabIntervalAtIndex:(NSUInteger)index {
if (!kiOS7Later) return 0;
ParagraphAttributeAtIndex(defaultTabInterval);
}
15. @property (nullable, nonatomic, copy, readonly) NSArray<NSTextTab *> *tabStops; 和 - (nullable NSArray<NSTextTab *> *)tabStopsAtIndex:(NSUInteger)index;
該組的作用就是獲取表示receiver
的tab stops
的NSTextTab
對(duì)象數(shù)組华坦。NSParagraphStyle
的封裝愿吹,只讀屬性。默認(rèn)值是12 TabStops季春,28.0 tab
間隔洗搂。
按位置排序的NSTextTa
b對(duì)象為段落樣式定義了制表位。
方法實(shí)現(xiàn)
- (NSArray *)tabStops {
if (!kiOS7Later) return nil;
ParagraphAttribute(tabStops);
}
- (NSArray *)tabStopsAtIndex:(NSUInteger)index {
if (!kiOS7Later) return nil;
ParagraphAttributeAtIndex(tabStops);
}
后記
本篇主要講述了 NSAttributedString分類(lèi)之Get paragraph attribute as property,感興趣的給個(gè)贊或者關(guān)注~~~~