美文网首页
2018-01-30

2018-01-30

作者: 不知道为什么 | 来源:发表于2018-01-30 11:04 被阅读0次

    CATextLayer 渲染速度 快鱼 UILabel所以以后争取用 CATextLayer 代替UILabel的代替 争取成熟后造轮子!

    记录

    -(NSDictionary *)attributes{
        if (!_attributes) {
            CTTextAlignment textAlignment = kCTTextAlignmentCenter;
            CTParagraphStyleSetting alignmentStyleSetting;
            alignmentStyleSetting.spec = kCTParagraphStyleSpecifierAlignment;
            alignmentStyleSetting.valueSize = sizeof(textAlignment);
            alignmentStyleSetting.value = &textAlignment;
            CTParagraphStyleSetting settings[]  = {
               alignmentStyleSetting
            };
            CTParagraphStyleRef style = CTParagraphStyleCreate(settings, 1);
            CTFontRef font = CTFontCreateWithName((CFStringRef)WZ6.fontName, 14, NULL);
            
            _attributes = [NSDictionary dictionaryWithObjectsAndKeys:
                           (__bridge id)font, kCTFontAttributeName,
                           (id)style, kCTParagraphStyleAttributeName, nil];
        }
        return _attributes;
    }
    

    相关文章

      网友评论

          本文标题:2018-01-30

          本文链接:https://www.haomeiwen.com/subject/ehgqzxtx.html