0

yahooのお天気アプリの画面遷移を真似てみたのですが、どの遷移なのかわかりませんでした。どんな手掛かり?

お時間をいただき、誠にありがとうございます。ありがとう

編集:

サブビューを持つslideView ctrlerがあります。スライダービューには画像があり、サブビューにはテキストがあります。スワイプを行うと、テキストを含むテキストビューは、ビューコントローラーのようにゆっくりと移動およびドラッグする必要があり、このインターンは、スライダー Ctrler のインスタンスである次のビューコントローラーでドラッグを開始する必要があります。

4

2 に答える 2

1

これを行う組み込みのトランジションはありません(ビュー自体とは異なるレートでframe/をトランジションしている画像について話していると思います)。centerおそらく自分で書く必要があります。ジェスチャ レコグナイザーとビュー アニメーションに関する基本的な知識が必要です。

基本的な効果は、2 つのイメージビュー (またはそれらのスーパー ビュー)centerを変更するときに、2 つのイメージ ビューのプロパティを同時に調整することです。frame(または、 のイメージ ビューを使用して を変更することで、これを実現できますcontentModeUIViewContentModeCenter)frameエフェクトの簡単なテストから始めて、そこからビルドすることをお勧めします。

たとえば、オートレイアウトの制約が次のように定義された 2 つのイメージ ビューを持つシーンを作成しました。

H:|[左画像ビュー][右画像ビュー]|
V:|[左画像ビュー]|
V:|[rightImageView]|

次に、 の幅の制約を定義し、その制約leftImageViewの に接続しました。次に、ジェスチャを処理できる があり、それに応じてこれを変更するだけです (自動レイアウトを使用すると、フレームの残りの部分がそこから自動的に計算されます)。IBOutletleftImageWidthConstraintUIPanGestureRecognizerleftImageWidthConstraint

- (void)handlePan:(UIPanGestureRecognizer *)gesture
{
    CGPoint translate = [gesture translationInView:gesture.view];
    static CGFloat width;

    if (gesture.state == UIGestureRecognizerStateBegan)
    {
        width = self.leftImageWidthConstraint.constant;
    }

    CGFloat newWidth = width + translate.x;

    if (newWidth < 0)
        newWidth = 0;
    else if (newWidth > self.view.bounds.size.width)
        newWidth = self.view.bounds.size.width;

    self.leftImageWidthConstraint.constant = newWidth;

    // if you let go, animate the views to their final position

    if (gesture.state == UIGestureRecognizerStateEnded)
    {
        // if more than half way, set left view's target width to take up full width, 
        // otherwise set left view's target width to zero

        if (newWidth > (self.view.bounds.size.width / 2.0))
            newWidth = self.view.bounds.size.width;
        else
            newWidth = 0;

        // animate the changing of the constraint (and thus the `frame`) accordingly

        self.leftImageWidthConstraint.constant = newWidth;
        [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
            [self.view layoutIfNeeded];
        } completion:nil];
    }
}

したがって、パンすると、2 つの画像はクリップされたフレーム内の中央に配置されます。

ここに画像の説明を入力

これは、アイデアの非常に基本的な実装です。ただし、実装の詳細 (カスタム コンテナーとサブビュー、自動レイアウトとそうでないものなど) は山ほどあるため、これらの質問のいくつかに答えるまで、より具体的に説明するのは難しいでしょう。

于 2013-10-25T20:42:37.733 に答える
0

デフォルトではありませんが、古いアプリで同様のことを達成しました

  1. isFromLeftSideビューとそれに応じて設定された検出にジェスチャを登録します

  2. 以下を呼び出します。要件に従ってこれを微調整します

     [self.view addSubview:mySlidingView];
            mySlidingView.frame = // set offscreen frame, in the direction you want it to appear from depending on flag isFromLeftSide
            [UIView animateWithDuration:8.0 
                             animations:^{
                                 mySlidingView.frame = // desired end location
                                    }];
    
于 2013-10-25T20:25:45.993 に答える