iOS UIView简单缩放动画
@interface ViewController () {
UIView *animationView;
UIButton *button;
CGPoint animationPoint;
} @end
初始化button和动画的view
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor]; // 创建Button
button = [UIButton buttonWithType:UIButtonTypeSystem];
button.layer.borderWidth = 0.5f;
button.layer.cornerRadius = 7.0f;
button.frame = CGRectMake(, , , );
[button setTitle:@"动画" forState:UIControlStateNormal];
[button addTarget:self action:@selector(showAnimation) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
// 动画缩放开始的点
animationPoint = CGPointMake(button.frame.origin.x + button.frame.size.width / , ); // 动画view
animationView = [[UIView alloc] initWithFrame:CGRectMake(, button.frame.origin.y + button.frame.size.height + , , )];
animationView.backgroundColor = [UIColor grayColor];
animationView.layer.cornerRadius = 7.0f;
animationView.alpha = 0.0f;
[self.view addSubview:animationView];
}
动画的处理方法
- (void)showAnimation { CGFloat offsetX = animationPoint.x - self.view.frame.size.width / ;
CGFloat offsetY = animationPoint.y - animationView.frame.size.height / ; if (animationView.alpha == 0.0f) {
// 动画由小变大
animationView.transform = CGAffineTransformMake(0.01, , , 0.01, offsetX, offsetY); [UIView animateWithDuration:0.3f animations:^{
animationView.alpha = 1.0f;
animationView.transform = CGAffineTransformMake(1.05f, , , 1.0f, , ); } completion:^(BOOL finished) {
[UIView animateWithDuration:0.1f animations:^{
animationView.transform = CGAffineTransformMake(, , , , , );
} completion:^(BOOL finished) {
// 恢复原位
animationView.transform = CGAffineTransformIdentity;
}];
}]; } else { // 动画由大变小
animationView.transform = CGAffineTransformMake(, , , , , );
[UIView animateWithDuration:0.2 animations:^{
animationView.transform = CGAffineTransformMake(0.01, , , 0.01, offsetX, offsetY);
} completion:^(BOOL finished) {
animationView.transform = CGAffineTransformIdentity;
animationView.alpha = 0.0f;
}];
} }
动画效果图
iOS UIView简单缩放动画的更多相关文章
- 【iOS】图片缩放动画
iOS 开发中,可用 UIView 的下述方法实现图片的缩放动画效果: + transitionWithView:duration:options:animations:completion: 示例代 ...
- ios移动旋转缩放动画
//移动旋转动画效果 CATransform3D rotate = CATransform3DMakeRotation(70.0 * M_PI / 180.0, 0.0, 0.0, 1.0); CAT ...
- ios 学习总结之动画(转)
转自:http://blog.sina.com.cn/s/blog_a85effc301012wu4.html UIView的,翻转.旋转,偏移,翻页,缩放,取反的动画效果 翻转的动画 //开始动 ...
- iOS开发笔记10:圆点缩放动画、强制更新、远程推送加语音提醒及UIView截屏
1.使用CAReplicatorLayer制作等待动画 CALayer+CABasicAnimation可以制作很多简单的动画效果,之前的博客中介绍的“两个动画”,一个是利用一张渐变色图片+CABas ...
- iOS开发UI篇—iOS开发中三种简单的动画设置
iOS开发UI篇—iOS开发中三种简单的动画设置 [在ios开发中,动画是廉价的] 一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView b ...
- iOS:抽屉侧滑动画两种形式(1、UIView侧滑 2、ViewController侧滑)
前言: 在iOS中抽屉动画是很常用的一种技术,使用它有很炫的体验效果,为app增添特色,形式就两种,一个是UIView的侧滑,另一个就是ViewController的侧滑. 实现方式: 抽屉侧滑动画有 ...
- ios uiview封装动画(摘录)
iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...
- IOS UIVIEW layer动画 总结(转)
转发自:http://www.aichengxu.com/article/%CF%B5%CD%B3%D3%C5%BB%AF/16306_12.html IOS UIVIEW layer动画 总结, ...
- iOS UI-三种简单的动画设置
一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView beginAnimations:nil context:nil]; //设置动画时长 ...
随机推荐
- nslookup 查询IPv6
> nslookup> set type=AAAA > ipv6 domain name (ipv6.google.com, time.buptnet.edu.cn)
- embed 隐藏播放器显示
昨天在页面做音频播放的时候,客户要求仅仅有声音.不显示播放器. 百度搜到解决方法: <embed id="embed_sound_id" src="test.mp3 ...
- cdoj 65 CD Making 水题
CD Making Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/65 De ...
- box-flex等分总结
首先要知道在应用 box-flex 时必须给父容器定义 css 属性 display:box 其子容器才可以进行划分. .box{ display: -webkit-box; display: -mo ...
- 剑指 offer set 10 栈的压入、弹出序列
总结 1. 通过按位对比来判断, 没有更优的方法了
- javascript 拷贝
拷贝简单分为浅拷贝与深度拷贝,即给定一个对象,生成一个相同的对象. 浅拷贝 function copy(source,destiny){ destiny = destiny || {}; if(typ ...
- tq2440开发板基本配置
时钟配置及分配 tq2440的晶振频率是12MHz,在uboot中有如下语句: #define S3C2440_CLKDIV 0x05 /* FCLK:HCLK:PCLK = 1:4:8, UCL ...
- 修改Intellij Idea 创建maven项目默认Java编译版本
在使用Intellij Idea 创建Maven项目时,默认的Java Language是1.5,虽然可以在Project Structrue中修改,但是每次pom.xml文件有变化时,工程又会重置到 ...
- Redis客户端Java服务接口封装
最近在学习Redis并集成到Spring中去,发现Spring的RedisTemplate并不好用,还没有MongoTemplate好用. 而且发现Jedis和ShardedJedis的方法非常多,覆 ...
- VirtualBox 导入.vdi文件时报“uuid is exists”错误
解决办法: 1.要安装的.vdi文件所在目录:D:\developTools\vm\RedHatLinux1.vdi 2.找到VirtualBox的安装目录,这里是D:\Program Files\O ...