@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. IE6文字溢出BUG(多出来的猪问题)

    在IE6下使用浮动可能会出现文字重复的情况. 在IE6下,浮动层之间有注释文字的话,之前那个浮动层的内容文字就有可能遭遇一个“隐形”的复制,但是代码里查看文字可并没有多出来. 看个例子: HTML & ...

  2. Windows常用性能计数器总结

    基础监控: Processor:% Processor Time CPU当前利用率,百分比 Memory:Available MBytes 当前可用内存,兆字节(虚拟内存不需要监控,只有当物理内存不够 ...

  3. Mac OS增删环境变量

    一.首先查看shell版本 使用命令echo $SHELL 如果输出的是:csh或者是tcsh,就是C Shell.如果输出的是:bash,sh,zsh,就是Bourne Shell的一个变种. Ma ...

  4. javascript优化

    javaScript是一门解释性的语言.它不像java.C#等程序设计语言.由编译器先进行编译再运行.而是直接下载到用户的客户端进行执行.因此代码本身的优劣就直接决定了代码下载的速度以及执行的效率. ...

  5. ueditor 编辑器再thinkphp中使用 解决转义问题

    在前台common.php文件中加入下面的函数就可以解决了 <?php //取消thinkphp里面的转义 if (get_magic_quotes_gpc()) { function stri ...

  6. Ubuntu下很给力的下载工具

    Windows下的下载工具--迅雷,之所下面载速度快,乃是它能搜索资源.为己所用,而不是只从原始地址这单一资源处下载. Ubuntu下也有类似的工具,那就是aira2. aira2是一个命令行下载工具 ...

  7. JavaScript Design Patterns: Mediator

    The Mediator Design Pattern The Mediator is a behavioral design pattern in which objects, instead of ...

  8. 淘宝 印风 UDF

    http://blog.csdn.net/zhaiwx1987/article/details/6902623

  9. iOS开发,hook系统Objective-C的函数

    我们都知道在windows下可以通过API轻松的hook很多消息,IOS也可以实现hook的功能. 建立一个 TestHookObject类 // // TestHookObject.m // Tes ...

  10. 慎用preg_replace危险的/e修饰符(一句话后门常用)

    要确保 replacement 构成一个合法的 PHP 代码字符串,否则 PHP 会在报告在包含 preg_replace() 的行中出现语法解析错误     preg_replace函数原型: mi ...