博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
切换view的动画
阅读量:7211 次
发布时间:2019-06-29

本文共 1670 字,大约阅读时间需要 5 分钟。

代码:

#import "MainViewController.h"@interface MainViewController ()@end@implementation MainViewController- (void)viewDidLoad{    [super viewDidLoad];        UIView *view1 = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];    view1.backgroundColor = [UIColor blueColor];        UIView *view2 = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];    view2.backgroundColor = [UIColor yellowColor];    [self.view addSubview:view1];    [self.view addSubview:view2];}-(void) changeView{    NSLog(@"change view");    CGContextRef context = UIGraphicsGetCurrentContext();    [UIView beginAnimations:nil context:context];    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];    [UIView setAnimationDuration:1.0];           [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];    [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];        [UIView setAnimationDelegate:self];    [UIView setAnimationDidStopSelector:nil];    [UIView commitAnimations];}-(void) changeView2{    CATransition *animation = [CATransition animation];    [animation setDuration:1.25f];    [animation setTimingFunction:[CAMediaTimingFunction                                  functionWithName:kCAMediaTimingFunctionEaseIn]];    [animation setType:kCATransitionReveal];    [animation setSubtype: kCATransitionFromRight];    [self.view.layer addAnimation:animation forKey:@"Reveal"];        [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];       [CATransaction commit];}-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{    [self changeView];}@end

 

转载于:https://www.cnblogs.com/code-style/p/4010616.html

你可能感兴趣的文章
关键时刻不可或缺的5款高科技紧急应用
查看>>
NSA方程式泄漏工具包浅析
查看>>
微服务,我们如何与你相处
查看>>
中国人工智能学会通讯——KS-Studio:一个知识计算引擎 1.2 知识图谱构建
查看>>
“Redirect to SMB”漏洞影响所有版本的Windows
查看>>
东方通没有创造中间件 却在定义中间件的“化蝶”
查看>>
物联网其实只是一个话题
查看>>
CloudCC:2017年下半年企业移动CRM市场风向窥测
查看>>
《并行计算的编程模型》一3.8.3 原子交换和条件交换
查看>>
备份不等于归档,在智能归档中备份资产!
查看>>
首届渣打科营编程马拉松赛初赛圆满结束
查看>>
三大超算军团加速布局 中科曙光E级超算预研项目正式启动
查看>>
高计算密度+低功耗!浪潮新一代高密度服务器SA5248M4横空出世
查看>>
GPU驱动“后摩尔定律时代” 为HPC和深度学习提供强大加速动力
查看>>
工信部副部长怀进鹏:信息产业呈现四大发展特点
查看>>
专访uPlane陈宏强:手机遥控固定翼飞机还是蓝海
查看>>
读懂Android中的代码混淆
查看>>
新IT运维模式下,全栈溯源助你解应用性能监控难题
查看>>
云存储标准应运而生
查看>>
物联网创新领域的三大驱动性趋势
查看>>