簡體   English   中英

CABasicAnimation正在慢慢關閉我的應用

[英]CABasicAnimation is slowly down my app

添加CABasicAnimation時性能下降。 我的應用程序運行緩慢。 如果我刪除它,一切都會很順利。 我試圖使用以下方法將動畫放在后台線程中

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^() {
});

但沒有運氣。 我能做什么? 這是我用來創建動畫的代碼。 非常感謝!

NSArray *fromColors = gradientLayer.colors;
NSArray *toColors = [self chooseGradientColors:flag];

[gradientLayer setColors:toColors];

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"colors"];

animation.fromValue = fromColors;
animation.toValue = toColors;
animation.duration = kGradientDuration;
animation.fillMode = kCAFillModeBoth;
animation.removedOnCompletion = NO;
animation.repeatCount = HUGE_VALF;
animation.autoreverses = YES;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

//Add the animation to layer
[gradientLayer addAnimation:animation forKey:@"animateGradient"];

嘗試設置layer.shouldRasterize = YES; 看看是否可以改善效果。

我已經使用此鏈接來解決我的問題,可能是幫助您CAGradientLayer,尺寸調整不佳,旋轉撕裂。 (隨附問題的視頻)謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM