用CATextLayer来实现一个UILabel
2018-07-20 来源:open-open
CATextLayer *textLayer = [CATextLayerlayer];
textLayer.frame =CGRectMake(100,100,100,100);
[self.view.layeraddSublayer:textLayer];
textLayer.foregroundColor = [UIColorblackColor].CGColor;
textLayer.alignmentMode =kCAAlignmentJustified;
textLayer.wrapped =YES;
UIFont *font = [UIFontsystemFontOfSize:15];
CFStringRef fontName = (__bridgeCFStringRef)font.fontName;
CGFontRef fontRef =CGFontCreateWithFontName(fontName);
textLayer.font = fontRef;
textLayer.fontSize = font.pointSize;
CGFontRelease(fontRef);
NSString *text =@"Cupid laid by his brand, and fell asleep";
textLayer.string = text;
textLayer.contentsScale = [UIScreen mainScreen].scale; // 在Retina显示
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
下一篇: iOS简单视频播放代码
最新资讯
热门推荐