11

メインの UIView にはUIView_1、 との 2 つのサブビューが含まれていますUIView_2
にはUIView_2、 を表示または非表示にするボタンがありますUIView_1
たとえば、ユーザーがボタンをタッチして を表示するUIView_1と、下UIView_1にスライドし、UIView_2トランジションで下に押します。
アニメの知識はほとんどありません。誰かが参照用のサンプル コードを表示できますか?
CGAffineTransformMakeTranslation を使用する必要がありますか?
ありがとう。ここに画像の説明を入力

4

3 に答える 3

20

それほど複雑なものは必要ありません。ビューのフレーム サイズを変更するだけです。

    NSTimeInterval animationDuration = /* determine length of animation */;
    CGRect newFrameSize = /* determine what the frame size should be */;
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:animationDuration];
    theViewToChange.frame = newFrameSize;
    [UIView commitAnimations];
于 2011-12-17T04:27:01.640 に答える
7

フェードイン/アウト効果で非表示/表示するだけ `

/表示する/

sliderView.hidden = NO;
sliderView.alpha = 0.1;
[UIView animateWithDuration:0.25 animations:^{
    sliderView.alpha = 1.0f;
} completion:^(BOOL finished) {
    // do some
}];

/隠す/

[UIView animateWithDuration:0.25 animations:^{
    sliderView.frame =  CGRectMake(130, 30, 0, 0);
    [sliderView setAlpha:0.1f];
} completion:^(BOOL finished) {
    sliderView.hidden = YES;
}];

`

于 2014-05-17T04:51:51.393 に答える
3

それはあなたが何をしたいかによって異なりますUIView_2

  1. UIView_1以下UIView_2を Interface Builder に配置します。

  2. UIView_2の下のすべてのスペースを占めるサイズUINavigationBar

  3. 次のコードを使用して、 のフレームのサイズを変更 ( を使用uiview2_resized_rect) するか、フレームをUIView_2移動/移動UIView_2( を使用uiview2_translated_rect) します。


CGRect uiview1_original_rect = UIView_1.frame;
CGRect uiview2_original_rect = UIView_2.frame;

CGRect uiview2_translated_rect = CGRectMake(uiview2_original_rect.origin.x, uiview2_original_rect.origin.y+uiview1_original_rect.size.height, uiview2_original_rect.size.width, uiview2_original_rect.size.height);

CGRect uiview2_resized_rect = CGRectMake(uiview2_original_rect.origin.x, uiview2_original_rect.origin.y+uiview1_original_rect.size.height, uiview2_original_rect.size.width, uiview2_original_rect.size.height-uiview1_original_rect.size.height);

[UIView animateWithDuration:0.300 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut|UIViewAnimationOptionBeginFromCurrentState animations:^{ //uncomment this and comment out the other if you want to move UIView_2 down to show UIView_1 //UIView_2.frame = uiview2_translated_rect; UIView_2.frame = uiview2_resized_rect; } completion:^(BOOL finished) {

}];

于 2011-12-17T04:33:33.767 に答える