2012-04-04 41 views

回答

7

整個應用程序?

嘗試在視圖控制器的內容視圖的背景層上設置speed屬性。速度= 2將是雙倍速度。您可以在所有視圖控制器的viewDidLoad方法中設置它。

您可能也可以創建一個UIWindow的自定義子類,並使該窗口對象將其視圖圖層上的speed屬性設置爲像makeKeyWindow這樣的瓶頸方法中的2.0。您需要讓所有應用的UIWindow對象使用您的自定義類。我不得不做一些挖掘來弄清楚如何做到這一點。

+4

子類'UIWindow'沒有必要。您可以在創建窗口後立即在應用程序委託中執行'self.window.layer.speed = 2.0f'。 – Costique 2012-04-04 20:51:12

3

蘋果沒有簡單的方法來改變它,因爲它會使不同應用程序之間的轉換過於異構。您可以將圖層的速度加倍,但這會影響其他動畫的時間。最好的方法是使用UIViewControler上的類別實現自己的轉換。

的UIViewController + ShowModalFromView.h

#import <Foundation/Foundation.h> 
#import <QuartzCore/QuartzCore.h> 

@interface UIViewController (ShowModalFromView) 
- (void)presentModalViewController:(UIViewController *)modalViewController fromView:(UIView *)view; 
@end 

的UIViewController + ShowModalFromView.m

#import "UIViewController+ShowModalFromView.h" 

@implementation UIViewController (ShowModalFromView) 

- (void)presentModalViewController:(UIViewController *)modalViewController fromView:(UIView *)view { 
    modalViewController.modalPresentationStyle = UIModalPresentationFormSheet; 

// Add the modal viewController but don't animate it. We will handle the animation manually 
[self presentModalViewController:modalViewController animated:NO]; 

// Remove the shadow. It causes weird artifacts while animating the view. 
CGColorRef originalShadowColor = modalViewController.view.superview.layer.shadowColor; 
modalViewController.view.superview.layer.shadowColor = [[UIColor clearColor] CGColor]; 

// Save the original size of the viewController's view  
CGRect originalFrame = modalViewController.view.superview.frame; 

// Set the frame to the one of the view we want to animate from 
modalViewController.view.superview.frame = view.frame; 

// Begin animation 
[UIView animateWithDuration:1.0f 
       animations:^{ 
        // Set the original frame back 
        modalViewController.view.superview.frame = originalFrame; 
       } 
       completion:^(BOOL finished) { 
        // Set the original shadow color back after the animation has finished 
        modalViewController.view.superview.layer.shadowColor = originalShadowColor; 
       }]; 
} 

@end 

這可以很容易地改變使用任何你想要的動畫過渡。希望這可以幫助!