UIView animation常用用法
来源:互联网 发布:移动5g网络 编辑:程序博客网 时间:2024/05/22 00:48
UIView 动画一:
利用UIView animation进行平移操作
- (IBAction)click:(id)sender {
[UIView beginAnimations:@"animations"context:nil];
[UIView setAnimationDuration:1.5];
CGRect frame = self.ball.frame;//imageView 的frame
frame.origin.y +=200 * flag;
flag =flag*( -1);//取反
self.ball.frame = frame;
[UIView commitAnimations];
/*
[UIView animateWithDuration:1.5 animations:^{
CGRect frame = self.ball.frame;
frame.origin.y += 100 * flag;//Y每次加100或减100
flag *= -1; //取反
self.ball.frame = frame;
}];
*/
}
不仅可以得用UIView实现一些常用的动画,还可以通过设置代理来监听动画的开始或结束,如:
- (IBAction)click:(id)sender {
[self.buttonsetAlpha:0.0];
[UIView beginAnimations:@"animations"context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationDelegate:self];//设置代理
[UIView setAnimationWillStartSelector:@selector(viewAnimationStart)];//监听开始
[UIView setAnimationDidStopSelector:@selector(viewAnimationDone)];//监听动画的结束
CGRect frame =self.ball.frame;
frame.origin.y +=100 * flag;
flag *= -1; //取反
self.ball.frame = frame;
[UIView commitAnimations];
}
-(void)viewAnimationStart{
NSLog(@"animation start-----");
}
- (void)viewAnimationDone {
NSLog(@"animation end-----");
[UIView beginAnimations:@"animationDone"context:nil];
[self.buttonsetAlpha:1.0];
[UIView commitAnimations];
}
UIView 动画之回调:
还可以通过回调来监听动画的完成
[UIView animateWithDuration:1.5animations:^{
CGRect frame = self.ball.frame;
frame.origin.y +=100 * flag;
flag *= -1;//取反
self.ball.frame = frame;
} completion:^(BOOL finished) {
NSLog(@"动画结束了。");
}];
- UIView animation常用用法
- UIView Animation的一些用法
- UIView Animation的一些用法
- UIView Animation的一些用法
- uiview animation
- UIView(animation)
- UIView Animation
- UIKit基础:8.UIView的常用属性 - Animation基本认识
- UIView move animation
- UIView, CALayer,Core Animation
- uiview的animation动画
- UIView下 Animation
- UIView Animation(二)
- UIView、Layer、Animation
- UIView animateWithDuration:animation:completion
- 使用UIView的animation
- iOS UIView Animation
- UIView动画animation
- oracle exchange partition 测试
- Spring Data JPA初使用
- Android.mk内的变量定义
- 15个最好的 HTML5 视频播放器
- 黑马程序员--苦逼的社会、彪悍的人生————纪念我在黑马的四个月
- UIView animation常用用法
- Android中使用Animation实现控件的动画效果以及Interpolator和AnimationListener的使用
- nvarchar和varchar的区别
- eclipse开发cocos2dx 3.2环境搭建之一: Android C\C++环境搭建(ndk r9d)
- 忽略performSelector警告
- 如何学习Linux
- poj 1159 Palindrome lcs+滚动数组
- POJ 3517 And Then There Was One(约瑟夫环-递推or模拟)
- C++与Java基本数据类型比较