CABasicAnimationを追加するとパフォーマンスが低下します。私のアプリは減速しています。私がそれを取り除くと、すべてがスムーズです。 私は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"];
はまた、あなたがずれ画像のスクリーンショットを添付することができます助けとなることがあり? – Alok
スクリーンショットの代わりに、上記のコードに基づいて動的グラデーションを実装しているので、実験中の問題を知らせるためにビデオをアップロードする必要があります。それはうまくいきますが、たとえば、テキストフィールドに関連するキーボードを表示しようとすると、このアクションはグラデーションのために非常に遅くなります。 動画をアップロードできるかどうかわかりません。 – Strafoffux
私はtableViewのstrechingヘッダーで作業していたときに、このような問題がありました。その場合、グラデーションは同じ速度でストレッチされませんでした。それのようなあなたのprobですか?これは私の問題を修正しましたhttp://stackoverflow.com/questions/17555986/cagradientlayer-not-resizing-nicely-tearing-on-rotation-video-of-issue-attac – Alok