zoukankan      html  css  js  c++  java
  • ios中两个view动画切换

    @interface ViewController ()
    @property(nonatomic,retain)UIView *redview;
    @property(nonatomic,retain)UIView *yellowview;
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        self.redview=[[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
        self.redview.backgroundColor=[UIColor redColor];
        [self.view addSubview:self.redview];
        [self.redview release];
        self.yellowview=[[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
      _yellowview.backgroundColor=[UIColor yellowColor];
        [self.view addSubview:_yellowview];
        //[_yellowview release];
    }
    
    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
        
        //转场动画,切换两个view  注意:如果要切换两个viewcontroller做转场要找到共同view;
        UIView *fromvalue=nil;
        UIView *tovalue=nil;
        if(_yellowview.superview){
            fromvalue=_yellowview;
            tovalue=_redview;
        }
        else{
            fromvalue=_redview;
            tovalue=_yellowview;
            
        }
        
      
        
        [UIView transitionFromView:fromvalue toView:tovalue duration:0.5 options:UIViewAnimationOptionTransitionFlipFromBottom completion:^(BOOL finished) {
           //这个api 原理   :
    //        1:[fromvalue.superview addSubview:tovalue];
    //        2:[fromvalue removeFromSuperview];
            NSLog(@"fromvalue-->%@",fromvalue.superview);
            NSLog(@"tovalue-->%@",tovalue.superview);
        }];
    }
  • 相关阅读:
    序列化和反序列化
    抽象类与接口
    为了忘却的纪念
    gmail和hotmail也有企业邮局
    tag's tag
    在互联网上裸奔
    音乐网站,可以自己弹琴,歌谱整理
    今天看了ning的介绍,很有意思
    昨天服务器出现问题,解决过程如下所述
    google Trends
  • 原文地址:https://www.cnblogs.com/gcb999/p/3189763.html
Copyright © 2011-2022 走看看