0

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

DixieFlatline
  • 7,895
  • 24
  • 95
  • 147
  • Can you put together a [mre]? Quick test, and I'm not seeing the issue you've shown in your gif... – DonMag Oct 03 '22 at 14:54

0 Answers0