- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章iOS基于CATransition实现翻页、旋转等动画效果由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
基于CATransition实现翻页、旋转、淡化、推进、滑入滑出、立方体、吮吸、波纹等动画效果.
首先看一下效果图:
下面贴上代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
#import "ViewController.h"
//获得屏幕的宽高
#define mainW [UIScreen mainScreen].bounds.size.width
#define mainH [UIScreen mainScreen].bounds.size.height
@interface ViewController ()
@property (nonatomic, strong) NSArray *typeArray;
@end
@implementation ViewController
- (
void
)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor greenColor];
//创建控件
[self creatControl];
_typeArray = @[kCATransitionFade, kCATransitionPush, kCATransitionMoveIn, kCATransitionReveal, @
"cube"
, @
"suckEffect"
, @
"oglFlip"
, @
"rippleEffect"
, @
"pageCurl"
, @
"pageUnCurl"
, @
"cameraIrisHollowOpen"
, @
"cameraIrisHollowClose"
];
}
- (
void
)creatControl
{
NSArray *titleArray = @[@
"淡化效果"
, @
"推进效果"
, @
"滑入效果"
, @
"滑出效果"
, @
"立方体效果"
, @
"吮吸效果"
, @
"翻转效果"
, @
"波纹效果"
, @
"翻页效果"
, @
"反翻页效果"
, @
"开镜头效果"
, @
"关镜头效果"
];
for
(
int
i = 0; i < titleArray.count; i++) {
CGFloat X = i % 2 == 0 ? mainW * 0.1 : mainW * 0.6;
CGFloat Y = 64 + i / 2 * mainW * 0.15;
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(X, Y, mainW * 0.3, mainW * 0.1)];
btn.tag = i;
[btn setBackgroundColor:[UIColor colorWithRed:0.6f green:0.7f blue:0.6f alpha:0.7f]];
[btn setTitle:titleArray[i] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(btnOnClick:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
}
- (
void
)btnOnClick:(UIButton *)btn
{
static
int
i = 0;
i = i == 0 ? 1 : 0;
self.view.backgroundColor = i == 0 ? [UIColor greenColor] : [UIColor yellowColor];
//创建CATransition对象
CATransition *animation = [CATransition animation];
//设置时间
animation.duration = 1.0f;
//设置类型
animation.type = _typeArray[btn.tag];
//设置方向
animation.subtype = kCATransitionFromRight;
//设置运动速度变化
animation.timingFunction = UIViewAnimationOptionCurveEaseInOut;
[self.view.layer addAnimation:animation forKey:@
"animation"
];
}
@end
|
CATransition.type动画类型:
1
2
3
4
5
6
7
8
9
10
11
12
|
kCATransitionFade
//淡化效果
kCATransitionPush
//推进效果
kCATransitionMoveIn
//滑入效果
kCATransitionReveal
//滑出效果
@
"cube"
//立方体效果
@
"suckEffect"
//吮吸效果
@
"oglFlip"
//翻转效果
@
"rippleEffect"
//波纹效果
@
"pageCurl"
//翻页效果
@
"pageUnCurl"
//反翻页效果
@
"cameraIrisHollowOpen"
//开镜头效果
@
"cameraIrisHollowClose"
//关镜头效果
|
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我.
原文链接:https://blog.csdn.net/hero_wqb/article/details/51556302 。
最后此篇关于iOS基于CATransition实现翻页、旋转等动画效果的文章就讲到这里了,如果你想了解更多关于iOS基于CATransition实现翻页、旋转等动画效果的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
出于某种原因,如果在添加 subview 后直接将动画添加到 subview 的图层,则 CATransition 将不会设置动画: transitionView = [[UIView alloc]
我正在使用一些最初取自 Apple 示例 ViewTransitions 的代码来相互交换两个 View 。 CATransition *animation = [CATransition anima
我有一个 UINavigationController。我将 VC1 设置为 rootViewController,并以编程方式从 VC1 加载 VC2,然后将自定义动画从 VC1 转到 VC2。标准
所以我最近才开始为 iPhone 开发一些简单的应用程序。我会说,我相当确定我对多 View 编程还没有深入的了解,但我正在努力学习。 我有一个程序,它最初是一个基于普通窗口的应用程序,因此我可以手写
CATransition 非常不寻常。考虑以下代码。 CATransition* trans=[CATransition animation]; trans.duration=0.5; trans.t
我正在尝试初始化 CATransition 实例,但 xCode 不断告诉我我正在使用未声明的标识符“CATransition”。您指的是“kCATransition”吗? 所讨论的行非常简单: CA
我在 Mac 应用程序中有一个简单的动画设置,其中页面控件交换了一些 View 。我非常接近获得我想要的类似分页的动画,但是有一个小问题。分页工作正常,新页面动画正确到位,但新页面还替换了动画之前的初
我在我的应用程序中使用 CATransition 动画,它工作正常,但有时会崩溃。 这是我的代码: -(void)_close_btn_click:(UIButton*)button { NSLo
我想用波纹过渡制作自定义segue。过渡有效,但没有波纹效果。这是我的代码 - (void)perform { // Add your own animation code here.
我正在两个 View Controller 上执行简单的从右到左的转换。动画效果完美,正是我想要的结果。但是,由于呈现/呈现的 View Controller 淡入/淡出,我在背景中看到黑色闪光。 我
我测试了 CATransition 字符串类型如下 @"suckEffect" @"spewEffect" @"genieEffect" @"unGenieEffect" @"rippleEffect
我有两个 View ,一个是aView,一个是bView,aView上有一个按钮,我点击按钮,我会跳转到bView,请看代码 -(IBAction)jump2b:(id)sender{ CATrans
可以延迟 CATransition 的动画吗?我尝试使用 startProgress 但它没有任何区别。 这就是我进行转换的方式: CATransition *animation = [CATrans
我正在尝试进行自定义转换以将 View Controller 插入堆栈。 我不知道是否有一种简单的方法可以将导航栏“锁定”在其位置上并在导航栏下进行转换。 我正在使用以下代码: CATransitio
获得了基本的 CATransition。作品。 animationKey = @"fadeIn"; [self.icon setImage:self.iconSelec
鉴于以下情况: let transition = CATransition() transition.duration = 0.5 transition.timingFunction
当我遇到这篇文章时,我正在研究 stackoverflow 试图找出如何在图层上制作 curl 动画:CATransition page curl from top 帖子的作者使用常量字符串 'pag
我有一个由五个 uiviewcontroller 组成的 uitabbarcontroller。 当我在第一个 uiviewcontroller 的 View 中点击一个按钮时,我希望 uiviewc
我正在尝试使 pushViewController 从左侧而不是右侧滑入,如下所示: Page14Controller * controller = [[Page14Controller alloc]
我正在开发一个应用程序,它在立方体上方显示四个 View ,您可以从右侧和左侧滑动滚动。我已经使用 CATransitions 轻松实现了这种交互,如下所示: [self.view1 addSubvi
我是一名优秀的程序员,十分优秀!