-3

フレームのみをアニメーション化する方法。ビュー全体ではなくサブビューと、そのサブビュー内にセグメント化されたコントロールボタンを追加する方法は? ボタンをクリックするとサブビューがポップアップするようにしたいのですが、背後の親ビューが見えるようにサブビューを半透明にする必要があります。

4

3 に答える 3

1

まず、あなたをsubview透明にします:

[subview setAlpha:0.5f];

そして、次のコードをaddSubView行の前に追加します。

CATransition *animation = [CATransition animation];
[animation setType:kCATransitionMoveIn];          // you can try carious options here
[animation setSubtype:kCATransitionFromRight];    // here too
[animation setDuration:0.3];
[animation setValue:@"Throb" forKey:@"MyAnimationType"];
[subview.layer addAnimation:animation forKey:nil];
于 2012-10-10T04:29:44.760 に答える
1

これを追加および削除する場合は、UIView グローバルを使用して、このビューにサブビューを追加します

        UIView *tempView=[[UIView alloc]initWithFrame:sel.view.frame];
        /////== Add your subviews in this tempView
        tempView.transform = CGAffineTransformMakeScale(1.3, 1.3);
        tempView.alpha = 0;
        [UIView animateWithDuration:.35 animations:^{
            tempView.alpha = 0.94;
            tempView.transform = CGAffineTransformMakeScale(1, 1);
        }];
       tempView.frame=CGRectMake(0, 0, 320, 480);
        [self.view addSubview:tempView];

アップデート :

最初に .h ファイルで UIView のオブジェクトを取得します

UIView *tempView;
BOOL isOpen;

メソッドでviewWillDidLoad:これを定義するだけです

isOpen = NO;

そして、このコードを使用した後

-(IBAction)btnSetting_Clicked:(id)sender
{
    if (isOpen) {
        isOpen = NO;
         [tempView removeFromSuperview];
    }
    else {
        isOpen = YES;
        tempView=[[UIView alloc]initWithFrame:self.view.frame];
        /////== Add your subviews in this tempView
        [tempView addSubview:yourSegControl];
        tempView.transform = CGAffineTransformMakeScale(1.3, 1.3);
        tempView.alpha = 0;
        [UIView animateWithDuration:.35 animations:^{
            tempView.alpha = 0.94;
            tempView.transform = CGAffineTransformMakeScale(1, 1);
        }];
        tempView.frame=CGRectMake(0, 0, 320, 480);
        [self.view addSubview:tempView];

    }
}

これがあなたを助けることを願っています..

:)

于 2012-10-10T04:32:34.833 に答える
0

メインビューにサブビューを追加できます

CGRect frame = CGRectMake(x, y, width, height); // Replacing with your dimensions
UIView *subView = [[UIView alloc] initWithFrame:frame];
[self.view addSubview:subView];

を使用して透明にすることができます

[subView setAlpha:0.2];

このビューには、任意の UI コントロールを追加できます。

これがあなたを助けることを願っています。

于 2012-10-10T04:29:16.953 に答える