神刀安全网

Some notes for TextKit

1.Use semantic approach for font in latter projects

  • Using a semantic approach to font names, such as UIFontTextStyleSubHeadline, helps avoid hard-coded font names and styles throughout your code — and ensures that your app will respond properly to user-defined typography settings as expected.
  • Font descriptors help you avoid the use of hardcoded font strings to set font types and styles.
  • Font descriptors are a type of descriptor language that allows you to modify fonts by applying specific attributes, or to obtain details of font metrics, without the need to instantiate an instance ofUIFont.

2. exclusionPaths property

NS_CLASS_AVAILABLE(10_0, 7_0) @interface NSTextContainer : NSObject <NSCoding, NSTextLayoutOrientationProvider>  // Default value : empty array  An array of UIBezierPath representing the exclusion paths inside the receiver's bounding rect. @property(copy, NS_NONATOMIC_IOSONLY) NSArray<UIBezierPath *> *exclusionPaths NS_AVAILABLE(10_11, 7_0);  @end 

You might have noticed that the exclusionPaths property expects an instance of NSArray; therefore each container can support more than one exclusion path.

3.Class clusters

Class clusters are a commonly used design pattern throughout Apple’s frameworks.A class cluster is simply the Objective-C implementation of the Abstract Factory pattern, which provides a common interface for creating families of related or dependent objects without specifying the concrete classes. Familiar classes such as NSArray and NSNumber are in fact the public interface to a cluster of classes.

4.Set hight of UITextView CGFLOAT_MAX

In any case, this is more than enough to allow the UITextView to scroll and accommodate long passages of text.

5. NSRange

来自Mattt的一篇: http://nshipster.com/nsrange/

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » Some notes for TextKit

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址