zoukankan      html  css  js  c++  java
  • 用drawAtPoint绘制文字

     

    从ios7开始,drawAtPoint:WithFont:等方法已经deprecated,取而代之应该使用drawAtPoint:WithAttributes方法,来设置字体的颜色和大小等,例:

        NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14], NSFontAttributeName, [UIColor colorWithRed:114/255.0f green:128/255.0f blue:137/255.0f alpha:1.0f], NSForegroundColorAttributeName, nil nil];  
                  
        [item.title drawAtPoint:textPoint withAttributes:attrs];  

    支持配置的属性名,在NSAttributedString.h里定义了:

    UIKIT_EXTERN NSString *const NSFontAttributeName NS_AVAILABLE_IOS(6_0);                 
    UIKIT_EXTERN NSString *const NSParagraphStyleAttributeName NS_AVAILABLE_IOS(6_0);        
    UIKIT_EXTERN NSString *const NSForegroundColorAttributeName NS_AVAILABLE_IOS(6_0);       
    UIKIT_EXTERN NSString *const NSBackgroundColorAttributeName NS_AVAILABLE_IOS(6_0);       
    UIKIT_EXTERN NSString *const NSLigatureAttributeName NS_AVAILABLE_IOS(6_0);              
    UIKIT_EXTERN NSString *const NSKernAttributeName NS_AVAILABLE_IOS(6_0);                 
    UIKIT_EXTERN NSString *const NSStrikethroughStyleAttributeName NS_AVAILABLE_IOS(6_0);   
    UIKIT_EXTERN NSString *const NSUnderlineStyleAttributeName NS_AVAILABLE_IOS(6_0);        
    UIKIT_EXTERN NSString *const NSStrokeColorAttributeName NS_AVAILABLE_IOS(6_0);          
    UIKIT_EXTERN NSString *const NSStrokeWidthAttributeName NS_AVAILABLE_IOS(6_0);          
    UIKIT_EXTERN NSString *const NSShadowAttributeName NS_AVAILABLE_IOS(6_0);               
    UIKIT_EXTERN NSString *const NSTextEffectAttributeName NS_AVAILABLE_IOS(7_0);            
    UIKIT_EXTERN NSString *const NSAttachmentAttributeName NS_AVAILABLE_IOS(7_0);            
    UIKIT_EXTERN NSString *const NSLinkAttributeName NS_AVAILABLE_IOS(7_0);                 
    UIKIT_EXTERN NSString *const NSBaselineOffsetAttributeName NS_AVAILABLE_IOS(7_0);        
    UIKIT_EXTERN NSString *const NSUnderlineColorAttributeName NS_AVAILABLE_IOS(7_0);        
    UIKIT_EXTERN NSString *const NSStrikethroughColorAttributeName NS_AVAILABLE_IOS(7_0);   
    UIKIT_EXTERN NSString *const NSObliquenessAttributeName NS_AVAILABLE_IOS(7_0);          
    UIKIT_EXTERN NSString *const NSExpansionAttributeName NS_AVAILABLE_IOS(7_0);            
    UIKIT_EXTERN NSString *const NSWritingDirectionAttributeName NS_AVAILABLE_IOS(7_0);      
    UIKIT_EXTERN NSString *const NSVerticalGlyphFormAttributeName NS_AVAILABLE_IOS(6_0); 
  • 相关阅读:
    QT学习笔记——06-Day16_C++_QT
    QT学习笔记——06-Day15_C++_QT
    QT学习笔记——06-Day14_C++_QT
    c++提高学习笔记——05-c++STLday13_贪吃蛇案例
    c++提高学习笔记——05-c++STLday12
    c++提高学习笔记——05-c++STLday11
    混子的 后缀数组 刷题记录
    POJ2528Mayor's posters 线段树,离散化技巧
    莫比乌斯反演 刷题记录
    P问题,NP问题,NPC问题学习笔记
  • 原文地址:https://www.cnblogs.com/allanliu/p/4254061.html
Copyright © 2011-2022 走看看