YYKit源碼探究(六十五) —— NSAttributedString分類之Get paragraph attribute as property(四)

版本記錄

版本號 時間
V1.0 2018.03.31

前言

iOS圈內(nèi)有幾個人大家基本都知道,比如說王巍、唐巧,還有YYKit框架的作者現(xiàn)任職于滴滴的郭曜源 - ibireme等。這里有一篇唐巧對他的專訪,還有他的 GitHub - Yaoyuan博客,這里貼出來框架YYKit 框架。接下來幾篇我們就一起來看一下這個框架。感興趣的可以看上面寫的幾篇。
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(三)

回顧

上一篇主要介紹了NSAttributedString分類的Get character attribute as property部分,這一篇主要看一下NSAttributedString分類的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;

下面我們詳細(xì)的看一下。

1. @property (nonatomic, readonly) NSTextAlignment alignment; 和 - (NSTextAlignment)alignmentAtIndex:(NSUInteger)index;

該屬性的作用就是文本對齊方式。(A wrapper for NSParagraphStyle)。

根據(jù)段落中包含的第一個腳本的行掃描方向,文本對齊被實(shí)現(xiàn)為左對齊或右對齊。默認(rèn)的對齊方式是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;

該組的作用獲取就是一個線段底部與下一個線段頂部之間的距離。該值永遠(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)為單位),以將其與以下段落分開。 這個值必須是非負(fù)的。 段落之間的空間通過添加前一段的段落空間和當(dāng)前段落的段落空間來確定。默認(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)容開始之間的距離,(NSParagraphStyle的包裝器),只讀。此屬性包含段落頂部與其文本內(nè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)邊距到段落第一行開頭的距離(以點(diǎn)為單位),這個值總是非負(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;

除第一個以外的receiver行的縮進(jìn),(NSParagraphStyle的包裝器),(只讀)。該屬性包含從文本容器的前導(dǎo)邊距到除第一個行之外的行的起始位置的距離(以點(diǎn)為單位),這個值總是非負(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的封裝,只讀屬性。無論任何附加圖形的字體大小或大小,此屬性都包含接收器中任何行將占用的點(diǎn)數(shù)的最小高度。 這個值必須是非負(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的封裝,只讀的。

無論任何附加圖形的字體大小或大小如何,該屬性都包含接收器中任何行將占用的最大點(diǎn)數(shù)。 這個值總是非負(fù)的。 超過此高度的字形和圖形將與相鄰行重疊;然而,最大高度為0意味著沒有線高度限制。 雖然此限制適用于行本身,但行間距會在相鄰行之間增加額外的空間。

方法實(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;

該組的作用就是基本書寫方向,NSParagraphStyle的封裝,只讀屬性。默認(rèn)值是NSWritingDirectionNatural

如果指定NSWritingDirectionNaturalDirection,則接收方將寫入方向解析為NSWritingDirectionLeftToRightNSWritingDirectionRightToLeft,具體取決于用戶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)文本寬度(如果沒有連字符斷開)與行寬度的比率小于hyphenation因子,則嘗試進(jìn)行連字。 當(dāng)段落的連字因子為0.0時,將使用布局管理器的連字因子。 當(dāng)兩者均為0.0時,連字符被禁用。

方法實(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中指定的最后一個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;

該組的作用就是獲取表示receivertab stopsNSTextTab對象數(shù)組。NSParagraphStyle的封裝,只讀屬性。默認(rèn)值是12 TabStops,28.0 tab間隔。

按位置排序的NSTextTab對象為段落樣式定義了制表位。

方法實(shí)現(xiàn)

- (NSArray *)tabStops {
    if (!kiOS7Later) return nil;
    ParagraphAttribute(tabStops);
}

- (NSArray *)tabStopsAtIndex:(NSUInteger)index {
    if (!kiOS7Later) return nil;
    ParagraphAttributeAtIndex(tabStops);
}

后記

本篇主要講述了 NSAttributedString分類之Get paragraph attribute as property,感興趣的給個贊或者關(guān)注~~~~

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容