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]; //设置动画时长 ...
随机推荐
- 71道经典Android面试题和答案
,,面试题1. 下列哪些语句关于内存回收的说明是正确的? (b ) A. 程序员必须创建一个线程来释放内存 B.内存回收程序负责释放无用内存 C.内存回收程序允许程序员直接释放内存 ...
- 博客标题栏增加一个"闪存“按钮
最近来博客园喜欢去闪存上看看,也就是一个类似微博的东西,但是貌似没看到哪里有这个按钮. 所以只要自己动手搞一个. 暴力猴js: // ==UserScript== // @name fwindpeak ...
- POJ 3159 Candies(SPFA+栈)差分约束
题目链接:http://poj.org/problem?id=3159 题意:给出m给 x 与y的关系.当中y的糖数不能比x的多c个.即y-x <= c 最后求fly[n]最多能比so[1] ...
- innodb 变量
http://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html
- mfc extention dll 與 normal dll 的區別
extention dll 1.指從MFC中繼承過來的DLL,一般要求使用共享MFC DLL進行連接,也要求調用者也使用MFC且使用共享MFC,如此可保證DLL與調用者有相同的MFC庫. 2.在使用資 ...
- repeater复杂表格的显示
首先简要的描述一下所要完成的事情:将某一个方言中的每一个声韵调组合,按照格式显示一个字 数据库中的信息:****,声母(Initial),韵母(Final),声调(Tone),一个汉字(Word),* ...
- 读懂IL代码就这么简单
原文地址:http://www.cnblogs.com/zery/p/3366175.html 一前言 感谢 @冰麟轻武 指出文章的错误之处,现已更正 对于IL代码没了解之前总感觉很神奇,初一看完全不 ...
- Spark SQL - DataFrame
1 Overview Spark SQL is a Spark module for structured data processing. It provides a programming abs ...
- Q_INVOKABLE与invokeMethod用法全解
在Qt/Qt Quick宏浅议一文中,我们将介绍Qt中经常使用的几个宏: Q_OBJECT, SIGNAL与SLOT, Q_SIGNALS 与 Q_SLOTS, Q_EMIT ,Q_INVOKABLE ...
- 全栈一路坑之使用django创建博客
最近在看一篇全栈增长工程师实战,然后学习里面的项目,结果发现作者用的技术太过老旧,好多东西都已经被抛弃了,所以结合着官方文档和自己的一些理解将错误的信息替换一下,边写边学习 准备工作和工具 作者说需要 ...