[英]Create an animation for UIView to coincide with UINavigationController push/pop
[英]Customize UINavigationController Push/pop animation with performance issues
我想使用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或更好的自定義動畫方法?
使用添加到UIViewController或子類UINavigationController中的新“容器”功能對自己的導航控制器進行編碼,並覆蓋所有push和pop方法。 后者可能會正常工作-我出於其他原因將其子類化,而我的子類也能正常工作。
許多人評論說,使用ios5容器中的新方法,現在可以重新創建大多數(如果不是全部)現有容器類。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.