How to get text in a CATextLayer to be clear

前端 未结 7 1821
不思量自难忘°
不思量自难忘° 2021-01-29 18:19

I\'ve made a CALayer with an added CATextLayer and the text comes out blurry. In the docs, they talk about \"sub-pixel antialiasing\", but that doesn\

7条回答
  •  北海茫月
    2021-01-29 19:13

    This is faster and easier: you just need to set contentsScale

        CATextLayer *label = [[CATextLayer alloc] init];
        [label setFontSize:15];
        [label setContentsScale:[[UIScreen mainScreen] scale]];
        [label setFrame:CGRectMake(0, 0, 50, 50)];
        [label setString:@"test"];
        [label setAlignmentMode:kCAAlignmentCenter];
        [label setBackgroundColor:[[UIColor clearColor] CGColor]];
        [label setForegroundColor:[[UIColor blackColor] CGColor]];
        [self addSublayer:label];
    

提交回复
热议问题