Pulsating UIView
Original Address:
http://tim-specht.de/?p=695
I needed to create a pulsating UIImageView (this will work for any subclass including itself of UIView without any changes) and solved that task using chained UIViewAnimation so I wanted to share that bunch of code with you.
//this method is used to setup all the stuff any initially starting the chain as mentioned
-(void)addLoadingImage{
UIImageView* pulseView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myImage.png"]];
pulseView.tag = MY_PULSE_TAG; //needed to keep track of the view afterwards, change this to whatever you want (use #define for better style, this is just a quick writedown!)
[self.view addSubview:pulseView];
[self pulseBig];
}
//animating the pulsing to big by changing the frame of the view which should be pulsing
-(void)pulseBig{
//needed to stop animation if view got removed, otherwhise we will get EXC_BAD_ACCESS
if(![self.view viewWithTag:MY_PULSE_TAG])
return;
[UIView beginAnimations:@"pulsing" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:1];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(pulseSmall)];
[[self.view viewWithTag:MY_PULSE_TAG] setFrame:myBigFrame];
[UIView commitAnimations];
 
}
//pulsing the view small!
-(void)pulseSmall{
//needed to stop animation if view got removed, otherwhise we will get EXC_BAD_ACCESS
if(![self.view viewWithTag:MY_PULSE_TAG])
return;
[UIView beginAnimations:@"pulsing" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:1];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(pulseSmall)];
[[self.view viewWithTag:MY_PULSE_TAG] setFrame:mySmallFrame];
[UIView commitAnimations];
}
Just fill in your two frames and the tag and you are ready to go. Please be aware that you need to set the origin of the bigger frame half of the changed size to be sure the center remains the same.
分享到:
相关推荐
这篇文章的标题是“CL-20水下爆炸冲击波与气泡脉动现象的数值模拟”,描述的是通过数值模拟方法研究高能炸药CL-20在有限水域内的爆炸现象,重点在于探究水下爆炸过程中冲击波衰减和气泡脉动现象。...
这篇文章的标题是《光纤激光器中脉冲孤子的动力学多样性》,而描述部分强调了在非线性耗散系统中,孤子在适当条件下也会脉动,并展现出多种有趣的动态特性。本文通过实时光谱技术,即色散傅里叶变换(DFT),揭示了...
- `ms_interference_oscillating_sphere.m` 和 `ms_interference_pulsating_sphere.m` 可能涉及到多声源干扰计算,处理多个振荡或脉动球体的声场相互作用。 - `LW_LJ_estimate_DUT_B_RSS_4.m` 和 `LW_LJ_estimate_...
标题中的“可旋转倾角的脉动热管可视化和测试平台”揭示了这个主题的核心——一个专门用于研究和测试脉动热管(Pulsating Heat Pipe, PHP)性能的实验装置,该装置具备旋转和倾斜功能,以模拟不同工况下的工作状态。...
1. 整流电路:整流电路是电源电路设计中的一个基本环节,它将交流电(AC)转换为脉动直流电(Pulsating DC)。整流通常由二极管或晶体管来完成,可以是半波整流或全波整流。半波整流只使用交流输入周期的一半,而全...
- **问题概述**:“Bright windows, blazing streetlights, pulsating neon...human beings are slowly being deprived of the dark night.” 这一段描述了现代社会中普遍存在的光污染现象,即由于城市中的强光照射...
部分内容中提到的关键字包括“pulsating cavity”(脉动空腔)、“cavitating flows”(空化流)、“multiphase flows”(多相流)。脉动空腔指的是在空泡内部压力波动导致空泡形态发生周期性变化的特性。空化流涉及...
2. 整流桥电路:使用二极管D101和D102组成的整流桥,将交流电(AC)转换为脉动直流电(Pulsating DC)。 3. 主开关电路:使用晶体管Q104, Q105, Q106等,按照一定的控制信号工作,将脉动直流电转换为高频交流电。 ...
本研究探讨了平板型脉动热管(Pulsating Heat Pipe, PHP)的传热性能,并采用中心复合设计(Central Composite Design, CCD)的方法来设计实验方案。通过对实验数据的分析,构建了一个以充液率、倾斜角度和加热量为...
二级减速器课程设计说明书,全英文书写 《Machine Parts Design》 Design Specification ...Topic Designation of Reducer College College of Mechanical and Electrical Engineering Major Mechanical ...
该存储库包含我在纽约州立大学奥斯威戈分校本科学习期间编写并用于恒星天体物理学研究的几个代码。 通常,这些代码处理来自“恒星天体物理学中的实验模块”及其附加功能“径向恒星脉冲”的输出数据。...