iphone应用中的动画效果之loading效果和界面切换效果
2011-04-11 10:43
791 查看
在应用开发中总要用到加载数据时候的loading动画效果 以下为一个loading效果实例,可以直接拿去用的:
在你的xxxController 头文件中声明:
UIView *colorView;
UIActivityIndicatorView *aciv;
初始化中定义:
aciv = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
colorView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)];
[colorView setBackgroundColor:[UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:0.4]];
加入以下方法:
- (void)addLoading{
aciv.activityIndicatorViewStyle=UIActivityIndicatorViewStyleWhite;
aciv.center=CGPointMake(screenWidth/2,screenHeight/2-10);
[self.view addSubview:colorView];
[aciv startAnimating];
[self.view addSubview:aciv];
}
- (void)removeLoading{
[colorView removeFromSuperview];
[aciv stopAnimating];
[aciv removeFromSuperview];
}
注释掉
//[self.view addSubview:colorView];
//[colorView removeFromSuperview];
则动画没有灰色背景
界面切换则可以有很多效果,如淡入淡出,放大,雾化,翻转等。
淡入淡出:
- (void)animateEaseInEaseOut:(CALayer*)laye delegate:(id)del{
CATransition *animationA = [CATransition animation];
[animationA setType:kCATransitionFade];
[animationA setDuration:1];
[animationA setDelegate:del];
[animationA setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[laye addAnimation:animationA forKey:@"EaseInEaseOut"];
}
翻转:
- (void)animateFlipView{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
[UIView commitAnimations];
}
在你的xxxController 头文件中声明:
UIView *colorView;
UIActivityIndicatorView *aciv;
初始化中定义:
aciv = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
colorView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)];
[colorView setBackgroundColor:[UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:0.4]];
加入以下方法:
- (void)addLoading{
aciv.activityIndicatorViewStyle=UIActivityIndicatorViewStyleWhite;
aciv.center=CGPointMake(screenWidth/2,screenHeight/2-10);
[self.view addSubview:colorView];
[aciv startAnimating];
[self.view addSubview:aciv];
}
- (void)removeLoading{
[colorView removeFromSuperview];
[aciv stopAnimating];
[aciv removeFromSuperview];
}
注释掉
//[self.view addSubview:colorView];
//[colorView removeFromSuperview];
则动画没有灰色背景
界面切换则可以有很多效果,如淡入淡出,放大,雾化,翻转等。
淡入淡出:
- (void)animateEaseInEaseOut:(CALayer*)laye delegate:(id)del{
CATransition *animationA = [CATransition animation];
[animationA setType:kCATransitionFade];
[animationA setDuration:1];
[animationA setDelegate:del];
[animationA setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[laye addAnimation:animationA forKey:@"EaseInEaseOut"];
}
翻转:
- (void)animateFlipView{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
[UIView commitAnimations];
}
相关文章推荐
- Android应用界面动画切换(主要Tabhost中跳转出来的动画效果解决[转]
- 控制界面切换的动画效果
- 编写最简单的 iPhone 界面切换应用
- 关于界面切换,动画效果问题
- 编写最简单的 iPhone 界面切换应用
- 编写最简单的 iPhone 界面切换应用
- 界面切换动画效果
- 《转载》两个activity界面间跳转切换动画效果
- Xcode界面切换添加动画效果
- 编写最简单的 iPhone 界面切换应用
- ACtivity实现欢迎界面并添加动画切换效果
- 实现Viewpager切换界面导航栏水波纹动画效果
- Xcode界面切换动画效果
- Android应用中使用ViewPager实现类似QQ的界面切换效果
- Android应用欢迎界面动态效果设置(补间动画)
- Activity界面启动和结束动画(仿微信界面切换效果)
- 两个activity界面间跳转切换动画效果
- Android 界面切换动画效果
- Android 动画效果(三):overridePendingTransition(界面切换动画)与LayoutTransition(布局动画)
- 界面切换动画效果