ios – Blurry animation of CATextLayer at start

0
59

[ad_1]

I am animating CATextLayer font size and i see some strange blurring of text at the start of animation.
I used CATextLayer because previous attempts with UILabel and scale animation resulted in similar crappy animation.

Definition:

CATextLayer *textLayer = [CATextLayer layer];
UIFont *font = [MyFonts semiBoldFontOfSize:14.0f];
textLayer.frame =  CGRectMake(0, 0, self.width - 44.0f, 300);
textLayer.string = self.viewModel.repeat;
textLayer.font = CTFontCreateWithName((__bridge CFStringRef) font.fontName, 14, nil);
textLayer.fontSize = font.pointSize;
textLayer.foregroundColor = MyApp.sharedInstance.useDarkMode ? UIColor.textColor1.CGColor : UIColor.darkGreyTwo.CGColor;
textLayer.contentsScale = [[UIScreen mainScreen] scale];
[_repeatsFreqLabel.layer addSublayer:textLayer];

Animation part:

let textLayer: CATextLayer = self.layer.sublayers?.first as! CATextLayer
// Animate font size up
let animation = CABasicAnimation(keyPath: "fontSize")
animation.fromValue = font.pointSize
animation.toValue = CGFloat(endFontSize)
animation.duration = duration
animation.autoreverses = true
textLayer.add(animation, forKey: "label")

This is how it looks:
enter image description here

[ad_2]