1

UIView を動的に追加する方法のほとんどを理解しましたが、今では uibutton がクリックされて uiview が表示されたときにアルファ アニメーションを作成しようとして立ち往生しています。ここで何が欠けているのかわからない:

- (void)buttonPressedAction:(id)sender
{
    CGRect frame;
    frame.origin.x = 0;
    frame.origin.y = 0;
    frame.size = self.scrIcon.frame.size;

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.0];

    UIView* view = [[UIView alloc] initWithFrame:frame];

    view.alpha = 1.0;

    [UIView commitAnimations];

    view.backgroundColor = [UIColor redColor];
    [scrIcon addSubview:view];


    /*
    UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
    CategoryViewController* theView = [sb instantiateViewControllerWithIdentifier:@"categoryIdentifier"];

    theView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:theView animated:YES];*/

}

scrIcon は UIScrollView です

ありがとう

4

3 に答える 3

4

このメソッドを試すことができます:animateWithDuration:animations:

UIView *view = [[UIView alloc] initWithFrame:self.scrIcon.frame];
view.backgroundColor = [UIColor redColor];
view.alpha = 0.0;

[scrIcon addSubview:view];

[UIView animateWithDuration:1.0 animations:^{
    view.alpha = 1.0;
}];
于 2012-10-05T04:01:27.187 に答える
2

コードを変更して、最初にビューを scrIcon に追加しました。次に、アニメーションを実行します。

- (void)buttonPressedAction:(id)sender
{
    CGRect frame;
    frame.origin.x = 0;
    frame.origin.y = 0;
    frame.size = self.scrIcon.frame.size;

    UIView* view = [[UIView alloc] initWithFrame:frame];

    view.alpha = 0.0f;

    view.backgroundColor = [UIColor redColor];
    [scrIcon addSubview:view];


    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.0];

    view.alpha = 1.0;

    [UIView commitAnimations];



}
于 2012-10-05T03:49:33.200 に答える
2

ViewDidLoad の場合: ビューを初期化するだけです…..

YourAnimateView = [[UIView alloc]initWithFrame:CGRectMake(-320, 0, 320, 320)];
[self.view addSubview:YourAnimateView];


In Your Button Action Method : just put this

[UIView animateWithDuration:0.5 delay:0.1 
                            options:UIViewAnimationOptionTransitionCurlDown
                         animations:^{
                             //animation code
                             YourAnimateView.frame = CGRectMake(0, 0, 320, 345);

                         } completion:^(BOOL finished) {
                             //completion code

                         }];
于 2012-10-05T04:15:16.747 に答える