iphone应用中的动画效果之loading效果和界面切换效果

在应用开发中总要用到加载数据时候的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];

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值