【问题标题】:Add CATransition animation to UIViewControllers将 CATransition 动画添加到 UIViewControllers
【发布时间】:2012-05-26 21:24:45
【问题描述】:

我想将CATransition 添加到我使用NSTimer 显示的UIViewControllers

-(void)playAction:(id)sender
{
[audioPlayer play];
[self performSelector:@selector(displayviewsAction:) withObject:nil afterDelay:11.0];
}

- (void)displayviewsAction:(id)sender
{  
 First *firstController = [[First alloc] init];
 firstController.view.frame = CGRectMake(0, 0, 320, 480);
 [self.view addSubview:firstController.view];
 [self.view addSubview:toolbar];
 [firstController release];   
 self.timer = [NSTimer scheduledTimerWithTimeInterval:23 target:self selector:@selector(Second) userInfo:nil repeats:NO];     
 }

-(void)Second 
{
Second *secondController = [[Second alloc] init];
secondController.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:secondController.view]; 
[self.view addSubview:toolbar];
[secondController release];
self.timer = [NSTimer scheduledTimerWithTimeInterval:27 target:self selector:@selector(Third) userInfo:nil repeats:NO];
}

UIViewControllers 从第一个变为第二个等时,我如何将CATransition 添加到这些UIViewControllers 中。

提前感谢所有想法。

【问题讨论】:

    标签: iphone core-animation transition


    【解决方案1】:

    使用这个 -

    -(void)Second {
        Second *secondController = [[Second alloc] init];
        secondController.view.frame = CGRectMake(0, 0, 320, 480);
    
        CATransition *transitionAnimation = [CATransition animation];
        [transitionAnimation setDuration:1];
        [transitionAnimation setType:kCATransitionReveal];
        [transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
    
        [self.view.layer addAnimation:transitionAnimation forKey:kCATransitionReveal];
    
        [self.view addSubview:secondController.view];
        [self.view addSubview:toolbar];
        [secondController release];
        self.timer = [NSTimer scheduledTimerWithTimeInterval:27 target:self selector:@selector(Third) userInfo:nil repeats:NO];
    }
    

    //你可以在这个里面定义自己的CATransition动画类型。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-28
    相关资源
    最近更新 更多