在ios5,ios6中正常执行的动画,但到ios7中不定时的会消失。
解决方案:在可能消失的地方加上“[UIView setAnimationsEnabled:YES]”,比如action方法,viewWillappear方法等。
网上暂时还没有与这个有关的问题,与这个类似:http://stackoverflow.com/questions/18880584/ios-7-animation-block-not-being-called
隐藏状态条
原来在ios6中是:
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- // Override point for customization after application launch.
- [[UIApplication sharedApplication] setStatusBarHidden:YES];
- return YES;
- }
现在在ios7中无效了。
快速解决:
在项目plist文件中修改为:
View controller-based status bar appearance 的值为NO。
但是我认为这个快速解决是没有按照苹果的思路来解决的,而且会有些问题,比如,当你在某个界面隐藏了status bar,退回到上一个界面时,status bar仍然是隐藏的。 首先,苹果把View controller-based status bar appearance默认的值设为YES,是有他的道理的,新系统下,苹果希望我们的viewcontroller去控制status bar,也就是说,我们大多数的界面应该是统一的,偶尔一些viewcontroller需要status bar特殊控制的,完全交给当前的viewcontroller来做。那么推荐解决方案:
保持View controller-based status bar appearance 的默认值为YES,然后在ViewController中重写prefersStatusBarHidden方法:
- - (BOOL)prefersStatusBarHidden
- {
- return YES;
- }
状态栏样式修改:
在在UIViewController或子类中实现以下两个方法:
- - (BOOL)prefersStatusBarHidden
- {
- return YES;
- }
- - (UIStatusBarStyle)preferredStatusBarStyle{
- return UIStatusBarStyleLightContent;
- }
在需要刷新状态栏样式的时候,调用
- - (void)setNeedsStatusBarAppearanceUpdate
在iOS 6 中,tintColor 可以用来给导航栏的背景着色、tab 栏、工具栏、搜索栏、搜索栏的 范围选择栏着色。而在iOS 7 中,给背景着色只需要使用barTintColor 属性就可以了,所以iOS7中barTintColor 取代原有的 tintColor, 原有的tintColor只修改对应bar上的按钮颜色。
- (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode 在ios7中过期
在ios7中使用:
- (CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)options attributes:(NSDictionary *)attributes context:(NSStringDrawingContext *)context
例如:
- CGSize size = CGSizeMake(screenSize.width - self.horizontalMargin * 4.f, 1000.f);
- if(IOS7_OR_LATER){
- CGRect textRect = [text boundingRectWithSize:size options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading) attributes:@{NSFontAttributeName:font} context:nil];
- self.contentWidth = self.contentWidth!=0.f?self.contentWidth:textRect.size.width;
- self.contentHeight = self.contentHeight!=0.f?self.contentHeight:textRect.size.height;
- }else{
- CGSize textSize = [text sizeWithFont:font constrainedToSize:size lineBreakMode:UILineBreakModeWordWrap];
- self.contentWidth = self.contentWidth!=0.f?self.contentWidth:textSize.width;
- self.contentHeight = self.contentHeight!=0.f?self.contentHeight:textSize.height;
- }