2

組み込みの iOS システム アニメーションのアニメーション プロパティ (速度とイージング カーブ) を取得することは可能ですか? 具体的にはUIStatusBarAnimationSlide、ステータス バーを表示または非表示にする場合です。現在、私はちょうどそれを観察していて、良い一致を思いつきました: デフォルトのアニメーション カーブを使用して .35 秒です。これは問題なく動作しますが、Apple は将来の iOS アップデートでこのようなアニメーションを変更する可能性があります。正確に一致させ、私が思いついたハードコードされた値に依存しないようにすることをお勧めします。

For what it's worth, here is the method my view controller is calling when I tap the view to hide the status bar and resize the view to fill the screen.

-(void)tappedView:(UIGestureRecognizer *)gestureRecognizer
{
    UIApplication *app = [UIApplication sharedApplication];
    // First, toggle the visibility of the status bar
    [[UIApplication sharedApplication] setStatusBarHidden:![app isStatusBarHidden] withAnimation:UIStatusBarAnimationSlide];
    // Then scale this view controller's view, attempting to match the built-in
    // UIStatusBarAnimationSlide animation
    [UIView animateWithDuration:.35
            animations:^{
                self.view.frame = [UIScreen mainScreen].applicationFrame;
            }];
}

As an aside, I'm surprised I couldn't find a built in way to handle resizing a VC's view when the status bar is hidden. After all, if the status bar doubles its height when a call is in progress, the view resizes automatically. Tell me I'm missing something and there's a way to get the view to grow automatically, too.

4

1 に答える 1

1

アプリで使用するコードの一部を次に示します。

- (void)application:(UIApplication *)application willChangeStatusBarFrame:
    (CGRect)oldStatusBarFrame {
    [UIView animateWithDuration:0.355f animations:^{
        if(floating_point_values_are_equal(oldStatusBarFrame.size.height, 20.0f)) {
            for(UIViewController* VC in self.tabBarController.viewControllers) {
                UIView* view = VC.view;
                [view setTransform:CGAffineTransformMakeScale(1.0f, 1.0f)];
            }
        } else {
            for(UIViewController* VC in self.tabBarController.viewControllers) {
                UIView* view = VC.view;
                CGFloat ratio = (view.frame.size.height - 20) / view.frame.size.height;

                [view setTransform:CGAffineTransformMakeScale(1.0f, ratio)];
            }
        }
    }];
}

基本的に、新しい画面サイズに応じてアプリ全体をスケーリングします。スケール比が大きな変化ではないため、これが機能するだけです。新しい iPhone の画面でこれを行うと、正しく表示されません。

于 2012-10-03T00:58:57.330 に答える