您的位置:首页 > 移动开发 > IOS开发

iOS 动画(3)

2017-02-24 23:14 141 查看
CATransition动画设置两个UIView

    UIView *magentaView =[[UIView alloc]initWithFrame:self.view.bounds];

    magentaView.backgroundColor =[UIColor magentaColor];

    [self.view addSubview:magentaView];

    UIView * gtayView =[[UIView alloc]initWithFrame:self.view.bounds];

    gtayView.backgroundColor =[UIColor lightGrayColor];

    [self.view addSubview:gtayView];

//提交

-(void)add{

    //    开始动画

    [UIView beginAnimations:@"animation" context:nil];

    [UIView setAnimationDuration:1.0];

    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

    //     提交动画

    [UIView commitAnimations];

}

//翻页

-(void)curl

{

    //    开始动画

    [UIView beginAnimations:@"animation" context:nil];

    [UIView setAnimationDuration:1.0f];

    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

    //     提交动画

    [UIView commitAnimations];

}

//移入

-(void)move

{

    CATransition *strasiton =[CATransition animation];

    strasiton.duration = 2.0f;

     //    使用kCATransitionMoveIn动画

    strasiton.type = kCATransitionMoveIn;

    //      指定动画方向,从左向右

    strasiton.subtype = kCATransitionFromLeft;

    [self.view.layer addAnimation:strasiton forKey:@"animation"];

    [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

}

//揭开

-(void)reveal

{

    

    CATransition *strasiton =[CATransition animation];

    strasiton.duration = 2.0f;

    //    使用kCATransitionReveal动画

    strasiton.type = kCATransitionReveal;

     strasiton.subtype = kCATransitionFromTop;

    [self.view.layer addAnimation:strasiton forKey:@"animation"];

    [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

}

//立方体

-(void)cube

{

    CATransition *trasiton =[CATransition animation];

    trasiton.duration = 2.0f;

    trasiton.type = @"cube";

    trasiton.subtype = kCATransitionFromLeft;

    [self.view.layer addAnimation:trasiton forKey:@"animation"];

    [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

}

//吸入

-(void)suck

{

    CATransition *trasiton =[CATransition animation];

    trasiton.duration = 2.0f;

    trasiton.type = @"suckEffect";

    trasiton.subtype = kCATransitionFromLeft;

    [self.view.layer addAnimation:trasiton forKey:@"animation"];

    [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

}

//翻转

-(void)oglFlip

{

    CATransition *trasiton =[CATransition animation];

    trasiton.duration = 2.0f;

    trasiton.type = @"oglFlip";

    trasiton.subtype = kCATransitionFromLeft;

    [self.view.layer addAnimation:trasiton forKey:@"animation"];

    [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

    

}

//水波

-(void)ripple

{

    CATransition *trasiton =[CATransition animation];

    trasiton.duration = 2.0f;

    trasiton.type = @"rippleEffect";

    trasiton.subtype = kCATransitionFromLeft;

    [self.view.layer addAnimation:trasiton forKey:@"animation"];

    [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  iOS 动画 CATransition
相关文章推荐