UI变化之动画效果
2015-11-24 10:19
357 查看
很多时候我们在需要动态的改变某一个场景下的显示。
最常见的一个场景就是view的最大化。
我们直接设置view的frame可以实现最大化,但是这样的最大化是突变的没有动画效果。
苹果可以将这种突变“放慢”速度来达到动画的效果。
一般有两种写法,在官方文档中如下记录:
In iOS 4 and later, you create an animation block using block objects. In earlier versions of iOS, you mark the beginning and end of an animation block using special class methods of the
第一种(IOS4之前做法):
第二种(iOS 4 and later)
可以使用块的方式:
最常见的一个场景就是view的最大化。
我们直接设置view的frame可以实现最大化,但是这样的最大化是突变的没有动画效果。
苹果可以将这种突变“放慢”速度来达到动画的效果。
一般有两种写法,在官方文档中如下记录:
In iOS 4 and later, you create an animation block using block objects. In earlier versions of iOS, you mark the beginning and end of an animation block using special class methods of the
UIViewclass.
第一种(IOS4之前做法):
[UIView beginAnimations:@"Resize" context:nil]; [UIView setAnimationDuration:1.0]; CGRect frame = self.myView.frame; frame.size.height += 30.0; self.myView.frame = frame; [UIView commitAnimations];
第二种(iOS 4 and later)
可以使用块的方式:
[UIView animateWithDuration:1.0 animations:^{ CGRect frame = self.myView.frame; frame.size.height += 30.0; self.myView.frame = frame; } completion:^(BOOL finished){ // whatever you need to do when animations are complete }];
相关文章推荐
- 如何从UIImage或者CGImage获取到图片的像素数据
- uiimage 转换为像素数据 以及从像素数据生成为uiimage
- 线程参数之 unique_ptr
- Machine Learning week 5 quiz: Neural Networks: Learning
- 为什么Java中1000==1000为false而100==100为true
- UIView状态监视
- kbuild-DEFINE(sym, val)
- Kibana User Guide [4.2] » Kibana 4.2 Release Notes
- iOS中 UIMPMediaPickerController播放系统音乐
- iOS中 UIMPMediaPickerController播放系统音乐
- ligerUI布局时,Center中的Tab高度太小问题解决
- UI学习第三章 UISwitch   UISegment    UIAlertView    UIActionsheet
- The requested URL ***** was not found on this serve
- 425 Unable to build data connection: Connection refused
- 【现身说法】玩游戏不如自己开发游戏
- Ignoring unknown package filter 'build-tools-23.0.0-preview'Warning: The package filter removed all
- HDU 1711 Number Sequence
- HDU 1711 Number Sequence
- UIView的contentMode属性总结
- Multi-Threading: How to Create Threads in UE4