美文网首页
CATextLayer == UILabel

CATextLayer == UILabel

作者: seventhboy | 来源:发表于2018-03-08 16:54 被阅读43次
 //create a text layer
    CATextLayer *textLayer = [CATextLayer layer];
    textLayer.frame = CGRectMake(0, 0, 200, 200);

// textLayer.position = CGPointMake(20, 20);//layer在view的位置 适用于跟随摸一个不固定长的的控件后面需要的
textLayer.foregroundColor = [UIColor blackColor].CGColor;//字体的颜色 文本颜色
textLayer.alignmentMode = kCAAlignmentLeft;//字体的对齐方式
textLayer.wrapped = YES;//默认为No. 当Yes时,字符串自动适应layer的bounds大小
UIFont *font = [UIFont systemFontOfSize:15]; //choose a font
CFStringRef fontName = (__bridge CFStringRef)font.fontName;
CGFontRef fontRef = CGFontCreateWithFontName(fontName);
textLayer.font = fontRef;
textLayer.fontSize = font.pointSize;
textLayer.contentsScale = [UIScreen mainScreen].scale;//文字模糊以Retina方式来渲染,防止画出来的文本像素化
CGFontRelease(fontRef); //与CFRelease的功能相当 当字体的null的时候不会引起程序出错
NSString *text = @"将阿萨德反馈啦圣诞节快乐房间里看撒健康的肌肤垃圾都是";
textLayer.string = text;
[self.layer addSublayer:textLayer];

相关文章

  • 2018-01-30

    CATextLayer 渲染速度 快鱼 UILabel所以以后争取用 CATextLayer 代替UILabel的...

  • CoreAnimation----CATextLayer

    CATextLayer 1. CATextLayer UILabel的精髓 在一个图层里面显示文字,可以借助图层代...

  • CATextLayer == UILabel

    // textLayer.position = CGPointMake(20, 20);//laye...

  • 第8章 专用图层

    8.2 CATextLayer UILabel的替代品: 这应该是一个用CATextLayer作为宿主图层的UIL...

  • CATextLayer

    CATextLayer也要比UILabel渲染得快得多。 很少有人知道在iOS 6及之前的版本,UILabel其实...

  • CALayer解析3:CATextLayer

    1.简介 CATextLayer提供了一个简单快速的文本渲染,与UILabel不同,不能设置Font,只能使用CT...

  • iOS Core Animation(九)- 图层性能

    文本 CATextLayer和UILabel都是直接将文本绘制在图层的寄宿图中。使用时需要尽可能地避免改变这些包含...

  • 【code_小马】Layer用来显示文字

    图片中:第一个是用CATextLayer实现的;第二个是用UILabel和CAGradientLayer实现的文字...

  • CATextLayer

    在界面上添加文本有两种;一种是: UILabel;第二种是:CATextLayer;最近在改到一个菜单的demo ...

  • CATextLayer

    在界面上添加文本有两种;一种是: UILabel;第二种是:CATextLayer;最近在改到一个菜单的demo ...

网友评论

      本文标题:CATextLayer == UILabel

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