CATextLayer提供了简单的文本布局 文本渲染的图层类
一.属性
@property(nullable, copy) id string;
文本只能是NSString或者NSAttributedString.默认为nil
@property(nullable) CFTypeRef font;
字体可以是CTFontRef,CGFontRef 或者字符串命名的字体.默认为Helvetica字体 只有在使用字符串的属性不是 NSAttributedString
@property CGFloat fontSize;
字体大小,默认为36.只有在使用字符串的属性不是 NSAttributedString. Animatable (Mac OS X 10.6 and later.)
@property(nullable) CGColorRef foregroundColor;
用foregroundColor颜色画string,默认为不透明的白色.只有在使用字符串的属性不是 NSAttributedString.Animatable (Mac OS X 10.6 and later.)
@property(getter=isWrapped) BOOL wrapped;
默认为No.当Yes时,字符串自动适应layer的bounds大小
@property(copy) NSString *truncationMode;
设置缩短的部位:kCATruncationNone,kCATruncationStart,kCATruncationEnd,kCATruncationMiddle
@property(copy) NSString *alignmentMode;
设置字体的排列格式:kCAAlignmentNatural,kCAAlignmentLeft,kCAAlignmentRight,kCAAlignmentCenter,kCAAlignmentJustified
参考资料:
CATextLayer