zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    森田疗法
    “不支持一个STA线程上针对多个句柄的WaitAll。”的解决方案
    烽火HG226信息
    祝贺小牛队得NBA总冠军
    .net4调用非托管代码出现:PInvoke调用导致堆栈不对称
    大怪路子逻辑
    C#内存复制与比较
    【收藏】UDP广播和多播
    Objectivec NSString
    Objectivec NSDictionary(NSMutableDictionary)
  • 原文地址:https://www.cnblogs.com/xianfeng-zhang/p/7766874.html
Copyright © 2011-2022 走看看