关于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];

转载请注明,错误请指正!

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

时间: 2024-07-30 09:40:24

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

iOS7中UIView的animateKeyframesWithDuration方法讲解

在iOS7中,给UIView添加了一个方法用来直接使用关键帧动画而不用借助CoreAnimation来实现,那就是animateKeyframesWithDuration 以下是使用源码: // // ViewController.m // // Created by YouXianMing on 14/11/26. // Copyright (c) 2014年 YouXianMing. All rights reserved. // #import "ViewController.h"

css ie7中overflow:hidden失效问题及解决方法

css兼容ie7: 做页面的时候用负边距居中的时候在IE7下面,父节点中的overflow:hiden失效的问题,查阅了一些资料,总结一下解决方法. 问题原因: 当父元素的直接子元素或者下级子元素的样式拥有position:relative属性时,父元素的overflow:hidden属性就会失效. 解决方法: 我们在IE7内发现子元素会超出父元素设定的高度,即使父元素设置了overflow:hidden. 解决这个bug很简单,在父元素中使用position:relative;即可解决该bug

实现iOS7上tableView的切割线像iOS6中的效果

iOS7上tableView的切割线左边短了一点,要实现和iOS6中的效果还是有方法的,UITableView头文件中个属性: @property (nonatomic)         UIEdgeInsets                separatorInsetNS_AVAILABLE_IOS(7_0)UI_APPEARANCE_SELECTOR; // allows customization of the frame of cell separators 在viewDidLoad里

实现iOS7上tableView的分割线像iOS6中的效果

iOS7上tableView的分割线左边短了一点,要实现和iOS6中的效果还是有方法的,UITableView头文件里个属性: @property (nonatomic)         UIEdgeInsets                separatorInsetNS_AVAILABLE_IOS(7_0)UI_APPEARANCE_SELECTOR; // allows customization of the frame of cell separators 在viewDidLoad里

ios7中 丰富多彩的UIViewController之间的切换

转载自:http://onevcat.com/2013/10/vc-transition-in-ios7/ 毫无疑问,ViewController(在本文中简写为VC)是使用MVC构建Cocoa或者CocoaTouch程序时最重要的一个类,我们的日常工作中一般来说最花费时间和精力的也是在为VC部分编写代码.苹果产品是注重用户体验的,而对细节进行琢磨也是苹果对于开发者一直以来的要求和希望.在用户体验中,VC之间的关系,比如不同VC之间迁移和转换动画效果一直是一个值得不断推敲的重点.在iOS7中,苹

ImageButton按压效果失效

LinearLayout中ImageButton的按压效果不起作用,如图 布局如下: <LinearLayout android:id="@id/ll_add_reply_face" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_

iOS中中UIView头文件详细解析

@interface UIView : UIResponder<NSCoding, UIAppearance, UIAppearanceContainer, UIDynamicItem> /** *  通过一个frame来初始化一个UI控件 */ - (id)initWithFrame:(CGRect)frame; // YES:能够跟用户进行交互 @property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteraction

iOS7中Objective-C和Foundation的新特性

转自kingzwt2009的专栏 注意事项(Ray):文章来自iOS 7 by Tutorials  iOS 7Feast的一部分(略) Objective-C 是最重要的iOS和OSX apps的开发工具.你可以使用其他语言的第三方框架开发apps,例如HTML&Javascript或者C#,但是如果你很快的写出一个超炫的高效率的原声apps你就需要使Objective-C. Foundation 是你开发Objective-C应用时用到的核心框架之一. 作为一名iOS开发者,非常有必要了解最

Swift中UIView类方法(animateWithDuration)的使用

需求:利用Swift语言实现OC语言中UIView类方法 [UIView animateWithDuration:0.5 animations:^{ bgView.alpha= 1; }]; 在Swift语言对应的方法为: class func animateWithDuration(duration: NSTimeInterval, animations: (() -> Void)!)  需要传入的参数有两个:1.duration:动画持续的时间(秒计)2.传入一个方法名(闭包,类似于函数指针