iphone – iOS 5,6和7的UI方法 – Xcode

前端之家收集整理的这篇文章主要介绍了iphone – iOS 5,6和7的UI方法 – Xcode前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我只是将我的 Xcode更新为5.我正在尝试构建我的应用程序,它在iOS7上看起来非常好,但我的工具栏有问题.工具栏上的按钮非常靠近状态栏.如果你做了一些改变,那么它会打破iOS 5和6的用户界面.
什么是最好的方法?为iOS 7构建不同的故事板被认为是一种好方法吗?有没有其他方法可以解决工具栏的问题?

解决方法

最佳方法是在进行任何更改之前向iOS版本添加大量检查.将以下宏放在* _prefix.pch文件

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

然后使用这样的iOS 7特定功能

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
    self.automaticallyAdjustsScrollViewInsets = YES;
    // or anything. Above line not specific to question,just an example
}

在Xcode 5 Interface Builder中,您还可以在iOS 7和iOS 7之间指定偏移量.大小检查器中的6或更低(Utilities(第三)列中的第四个选项卡)并在7和&之间切换. File Inspector中的7个渲染(Utilities列中的第一个选项卡).当您必须在7中的布局中考虑状态栏或导航栏时,这通常会发挥作用.

猜你在找的Xcode相关文章