关于iOS7中UIView效果失效问题的解决

近期想做一个跑马灯的效果,于是写出了如下的跑马灯效果的代码。。。但是调试发现,在iOS6下动画是可以执行的,但是在iOS7下动画并不执行,没有达到预期的效果。

[_scrollLabel sizeToFit];
    CGRect frame = _scrollLabel.frame;
    frame.origin.x = 320;
    _scrollLabel.frame = frame;
    [UIView setAnimationsEnabled:YES];
    [UIView beginAnimations:@"testAnimation" context:NULL];
    [UIView setAnimationDuration:10.f];
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationRepeatAutoreverses:NO];
    [UIView setAnimationRepeatCount:999999];
    frame = _scrollLabel.frame;
    frame.origin.x = -frame.size.width;
    NSLog(@"frame orgin:%f",frame.origin.x);
    _scrollLabel.frame = frame;
    [UIView commitAnimations];
然后在网上查了各种资料,都没有解决。。。最终发现,我的这个视图控制器是present模态化视图,在iOS7下模态化出来的视图UIView就出现问题了。。。果断把present换成了push。。。但是push又达不到prensent的效果,于是又模仿present,在push视图中实现present动画。代码如下:

一、push

MCLotteryListViewController *list = [[MCLotteryListViewController alloc]init];
    //list.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
//    [self presentViewController:list animated:YES completion:^{
//        
//    }];
    [UIView  beginAnimations:nil context:NULL];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.75];
    [self.navigationController pushViewController:list animated:NO];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO];
    [UIView commitAnimations];
二、pop

[UIView  beginAnimations:nil context:NULL];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:0.75];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO];
    [UIView commitAnimations];
    
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDelay:0.375];
    [self.navigationController popViewControllerAnimated:NO];
    [UIView commitAnimations];
转载请注明,错误请指正!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值