@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. C166 Interfacing C to Assembler

    Interfacing C to Assembler You can easily interface your C programs to routines written in XC16x/C16 ...

  2. PostgreSQL下,对汉字按拼音排序

    参考学习此文: http://blog.163.com/digoal@126/blog/static/163877040201173003547236/ 建库 postgres=# \l List o ...

  3. BZOJ 1061: [Noi2008]志愿者招募 费用流

    1061: [Noi2008]志愿者招募 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=1061 Description 申奥成功后,布布 ...

  4. cdoj 26 遮挡判断(shadow) 水题

    遮挡判断(shadow) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/26 ...

  5. Codeforces Round #188 (Div. 1) B. Ants 暴力

    B. Ants Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/317/problem/B Des ...

  6. Unity3D中使用Leap Motion进行手势控制

    Leap Motion作为一款手势识别设备,相比于Kniect,长处在于准确度. 在我的毕业设计<场景漫游器>的开发中.Leap Motion的手势控制作为重要的一个环节.以此,谈谈开发中 ...

  7. 有趣的动画视图集合:Android View Animations

    Android View Animations这个项目收集了各种有趣的动画效果. 所有效果: Attension Flash, Pulse, RubberBand, Shake, Swing, Wob ...

  8. [ES6] 14. Generator -- 1. yield & next()

    Generators in ECMAscript 6 are first-class coroutines that produce encapsulated suspended execution  ...

  9. javascript异步延时载入及推断是否已载入js/css文件

    <html> <head> <script type="text/javascript"> /**======================= ...

  10. Linux合并文件、去除重复行的命令

    Linux合并文件命令: awk '{printf("%s\n",$0)}' YQ-*101?.txt >  123.txt   linux去除重复行命令:cat YQ-10 ...