iOS之CATextLayer属性简介
Posted ForeverGuard
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iOS之CATextLayer属性简介相关的知识,希望对你有一定的参考价值。
1、CATextLayer简介
CATextLayer快速高效简单地来渲染纯文本、NSAttributedString
/* The text layer provides simple text layout and rendering of plain * or attributed strings. The first line is aligned to the top of the * layer. */ NS_ASSUME_NONNULL_BEGIN CA_CLASS_AVAILABLE (10.5, 2.0, 9.0, 2.0) @interface CATextLayer : CALayer { @private struct CATextLayerPrivate *_state; } //渲染的字符串 @property(nullable, copy) id string; //字体 @property(nullable) CFTypeRef font; //字号 @property CGFloat fontSize; //文字颜色 @property(nullable) CGColorRef foregroundColor; //是否换行,默认NO @property(getter=isWrapped) BOOL wrapped; //枚举:设置截断模式 @property(copy) NSString *truncationMode; //枚举:设置对其模式 @property(copy) NSString *alignmentMode; //文字是否像素化,默认NO @property BOOL allowsFontSubpixelQuantization; @end /* Truncation modes. */ CA_EXTERN NSString * const kCATruncationNone //不剪裁,默认 CA_AVAILABLE_STARTING (10.5, 3.2, 9.0, 2.0); CA_EXTERN NSString * const kCATruncationStart //剪裁开始部分 CA_AVAILABLE_STARTING (10.5, 3.2, 9.0, 2.0); CA_EXTERN NSString * const kCATruncationEnd //剪裁结束部分 CA_AVAILABLE_STARTING (10.5, 3.2, 9.0, 2.0); CA_EXTERN NSString * const kCATruncationMiddle //剪裁中间部分 CA_AVAILABLE_STARTING (10.5, 3.2, 9.0, 2.0); /* Alignment modes. */ CA_EXTERN NSString * const kCAAlignmentNatural //默认 CA_AVAILABLE_STARTING (10.5, 3.2, 9.0, 2.0); CA_EXTERN NSString * const kCAAlignmentLeft //左对齐 CA_AVAILABLE_STARTING (10.5, 3.2, 9.0, 2.0); CA_EXTERN NSString * const kCAAlignmentRight //右对齐 CA_AVAILABLE_STARTING (10.5, 3.2, 9.0, 2.0); CA_EXTERN NSString * const kCAAlignmentCenter //居中对齐 CA_AVAILABLE_STARTING (10.5, 3.2, 9.0, 2.0); CA_EXTERN NSString * const kCAAlignmentJustified //两端对齐 CA_AVAILABLE_STARTING (10.5, 3.2, 9.0, 2.0); NS_ASSUME_NONNULL_END
以上是关于iOS之CATextLayer属性简介的主要内容,如果未能解决你的问题,请参考以下文章
iOS - 如何在使用自定义 UIBezierPath 绘制的 CAShapeLayer 中设置 CATextLayer?