Core Animationでプッシュとポップのアニメーションをカスタマイズしたい!たとえば、次のように pushViewController にコードを記述します。
{
//save currrent view's snapshot`
m_curLayer = [self _ConstructLayerByView:self.view];
[super pushViewController:viewController animated:NO];
//save the next view's snapshot
m_nextLayer = [self _ConstructLayerByView:self.view];
//add these two new layers to self.view.layer, and add customized animations to them.
[self _PushAnimation];
}
アニメーションは期待どおりに動作しますが、パフォーマンスが悪いです。いくつかのプロファイリングの後、renderInContext が非常に遅いことがわかりました。私のスナップショット機能は次のとおりです。
+ (id)CaptureView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.frame.size, YES, [UIScreen mainScreen].scale);
CGContextRef contenxt = UIGraphicsGetCurrentContext();
[view.layer renderInContext:contenxt];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return (id) [newImage CGImage];
}
renderInContext を最適化する方法、またはアニメーションをカスタマイズするより良い方法があるかどうかを尋ねたいと思いますか?