@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简单缩放动画的更多相关文章

  1. 【iOS】图片缩放动画

    iOS 开发中,可用 UIView 的下述方法实现图片的缩放动画效果: + transitionWithView:duration:options:animations:completion: 示例代 ...

  2. ios移动旋转缩放动画

    //移动旋转动画效果 CATransform3D rotate = CATransform3DMakeRotation(70.0 * M_PI / 180.0, 0.0, 0.0, 1.0); CAT ...

  3. ios 学习总结之动画(转)

    转自:http://blog.sina.com.cn/s/blog_a85effc301012wu4.html UIView的,翻转.旋转,偏移,翻页,缩放,取反的动画效果   翻转的动画 //开始动 ...

  4. iOS开发笔记10:圆点缩放动画、强制更新、远程推送加语音提醒及UIView截屏

    1.使用CAReplicatorLayer制作等待动画 CALayer+CABasicAnimation可以制作很多简单的动画效果,之前的博客中介绍的“两个动画”,一个是利用一张渐变色图片+CABas ...

  5. iOS开发UI篇—iOS开发中三种简单的动画设置

    iOS开发UI篇—iOS开发中三种简单的动画设置 [在ios开发中,动画是廉价的] 一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView b ...

  6. iOS:抽屉侧滑动画两种形式(1、UIView侧滑 2、ViewController侧滑)

    前言: 在iOS中抽屉动画是很常用的一种技术,使用它有很炫的体验效果,为app增添特色,形式就两种,一个是UIView的侧滑,另一个就是ViewController的侧滑. 实现方式: 抽屉侧滑动画有 ...

  7. ios uiview封装动画(摘录)

    iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...

  8. IOS UIVIEW layer动画 总结(转)

    转发自:http://www.aichengxu.com/article/%CF%B5%CD%B3%D3%C5%BB%AF/16306_12.html   IOS UIVIEW layer动画 总结, ...

  9. iOS UI-三种简单的动画设置

    一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView beginAnimations:nil context:nil]; //设置动画时长 ...

随机推荐

  1. 启动Tomcat的时候遇到错误

    严重: IOException while loading persisted sessions: java.io.EOFException java.io.EOFException at java. ...

  2. Hadoop on Mac with IntelliJ IDEA - 9 解决Type mismatch in value from map问题

    修改陆喜恒. Hadoop实战(第2版)5.3排序的代码时遇到IO异常. 环境:Mac OS X 10.9.5, IntelliJ IDEA 13.1.5, Hadoop 1.2.1 异常具体信息如下 ...

  3. Active Low-Pass Filter Design 低通滤波器设计

    2nd order RC Low-pass Filter Center frequency    fc = 23405.13869[Hz] Q factor                  Q = ...

  4. IIS配置(安装IIS、.Net、更改IIS Log目录位置)

    #安装IIS..NetFramework 3.5 Import-Module servermanager Get-WindowsFeature web-* | ? {$_.Name -ne " ...

  5. Linux系统编程——进程间通信:命名管道(FIFO)

    命名管道的概述 无名管道,因为没有名字,仅仅能用于亲缘关系的进程间通信(很多其它详情.请看<无名管道>).为了克服这个缺点.提出了命名管道(FIFO).也叫有名管道.FIFO 文件. 命名 ...

  6. Codeforces Round #309 (Div. 1) C. Love Triangles dfs

    C. Love Triangles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/553/pro ...

  7. Spring MVC整合Velocity

    Velocity模板(VM)语言介绍 Velocity是一个基于java的模板引擎(template engine).它允许任何人仅仅简单的使用模板语言(template language)来引用由j ...

  8. Android如何完全调试framework层代码

    1 之前写过一篇文章:<Android实现开机调试system_process> 2 google的eclipse插件ADT的已经能够很方便的调试Android的apk了,但是调试的时候应 ...

  9. Android创建桌面快捷方式

    在桌面上创建特定界面的快捷入口,icon和title根据请求参数命名.在网上收集的一些相关资 料,在使用intent发送广播的时候,一些型号的收集会有问题,如魅族MX,红米,以及华为,使用setCla ...

  10. MySQL 5.7.12新增MySQL Shell命令行功能

      在最新发布的MySQL 5.7.12中有许多令人兴奋的新功能,对于MySQL开发者来说,最令人兴奋的莫不是新增的MySQL Shell了,其下载地址: http://dev.mysql.com/d ...