码迷,mamicode.com
首页 > 其他好文 > 详细

实现多个UIView之间切换的动画效果

时间:2014-07-02 10:25:29      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   cti   for   io   

@interface RootViewController (){
    UIView *view1;
    UIView *view2;
    int    flag;
}

@end

@implementation RootViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    flag = 1;
    
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(130, 65, 50, 35)];
    [button setTitle:@"点击" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 100, 320, 480)];
    view1.backgroundColor = [UIColor grayColor];
    
    view2 = [[UIView alloc]initWithFrame:CGRectMake(0, 100, 320, 480)];
    view2.backgroundColor = [UIColor orangeColor];
}

- (void)click{
    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.6f];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:NO];
    
    if (flag == 1) {
        
        [self.view addSubview:view1];
        flag = 2;
        
    }else if(flag == 2){
        
        [self.view addSubview:view2];
        flag = 1;
    }
    [UIView commitAnimations];
}

 

实现多个UIView之间切换的动画效果,布布扣,bubuko.com

实现多个UIView之间切换的动画效果

标签:style   blog   color   cti   for   io   

原文地址:http://www.cnblogs.com/hw140430/p/3819515.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!