iOS7 Transition Guide

API变化:
1、弃用 MKOverlayView 及其子类,使用类 MKOverlayRenderer
2、弃用 Audio Toolbox framework 中的 AudioSession API,使用AV Foundation framework 中的 AVAudioSesssion 类;
3、Core Location framework中的 CLRegion 类被 CLCircularRegion 代替,不过 CLRegion 类在同时支持 geographic和beacon regions的抽 象基类中继续存在;
4、CBCentral 类中的 UUID 属性被弃用,使用属性 identifier 代替;
5、UIKit framework中变化:
UIViewController 中属性 wantsFullScreenLayout 被弃用,因为iOS7及之后,view controllers将始终支持全屏布局;
UIPopoverController 不再提供箭头方向(arrow direction)的概念,改为展示方向(presentation direction)
  • UIColor objects that provided background textures for earlier versions of iOS are gone.

  • Many drawing additions to the NSString class are deprecated in favor of newer variants.

6、libsyscall 类库中的 gethostuuid 功能被弃用;
7、iOS7及以后,如果你要获取 iOS设备的MAC地址,系统会返回  02:00:00:00:00:00 。如果你需要identify设备,使用 UIDevice 的 属性 identifierForVendor 代替。(那些出于发布广告的目的使用identifier的apps,应当考虑使用 ASIdentifierManager的属性 advertisingIdentifier 代替。)
----------------------------------------- ----------------- --------华丽丽的分割线------- ----------------- --------------------------------------------------

昨晚WWDC2013苹果公司推出颠覆性的iOS7,目前来看,扁平化的设计没有赢得很多人的赞赏,其实我也有一点不是很明白,在审美上扁平化比拟物化更好看么?为什么要追求扁平化?不是为了颠覆而颠覆?
不过,与早先版本在视觉上有较大差异的iOS7,对于开发者来说,有一些需要注意的地方。比如
1、虚化控件的边界,透明的状态栏使布局全屏化,并提供在app运行时修改状态栏风格的方法;
2、如果你的app需要同时满足iOS6和iOS7,对于系统的UI,在iOS7中,会使用iOS7的扁平化风格,比如alertView,UIActionView;
总之,没有变化太多的地方。

此文根据苹果公司提供的文档 TransitonGuide.pdf 编写。

每个app 必须要满足的有以下三个条件:

1、升级app图标。在iOS7中,app图标是120*120像素(高分辨率)。

2、升级启动界面使其包括状态栏区域,如果之前不是这样。

3、在设计的时候,要支持视网膜屏和iPhone5,如果你之前没有这么做的话。

需要满足(非必须):

1、确保app界面的内容可以通过半透明的UI元素进行辨别---就像bars、keyboards以及透明的状态栏;在iOS7中,试图控制器将使用全屏布局。

2、重新设计定制 bar button icons. 在iOS7中,bar button icons 扮演不在那么重要的角色,并且风格上有一些改变。

3、通过使用布局来设计没有边框的buttons,不要再使用提供的button背景图片。

4、使用硬编码来检测UI values,比如大小sizes和位置positions,并用系统动态提供的values来代替。当布局改变的时候,使用Auto Layout来自动适应。

5、检查你的app的places,如果UIKit的controls和views的metrics(度量)和风格的变化影响布局和显示的话。

6、采用动态风格。在iOS7中,用户可以调整他们看到的app中文字的大小。只有当你使用动态设计,才能让text根据用户指定的文字大小适当的改变。

7、确保你的app不会根据新的控制中心的手势或者导航控制器的返回swipe手势做出不合适的响应,特别是你在自定义手势识别的时候。

8、重新学习阴影(drop shadows)、渐变(gradients)和斜面(bezels)的使用。因为iOS7的审美是平滑和有层次感的------不再强调在UI元素上拟物化效果的使用------你可能会重新考虑这些效果。

9、如果有必要,为iOS6把你的app进行最优化的升级----比如使用自动布局(Auto Layout)和故事板(storyboards)------并且确保app中没有使用被弃用的API。


但是如果你一定要继续支持iOS6

Note: 在运行iOS7的设备上,所有的系统UI----像警告框alerts和通知notifications---将使用iOS7界面风格,即使你的app正在使用之前的UI设计。

 

① Using Interface Builder to Support Multiple App Versions

Xcode5 的 Interface Builder 拥有一个新功能可以帮助你在继续支持更早版本的同时,把你的应用移植到iOS7.

 

 

Get a preview of how the UI updates you make affect an earlier version.

预览你对UI的升级对earlier version的影响

  1. While viewing the iOS 7 storyboard or xib file on the canvas, open the assistant editor.

  2. Open the Assistant pop-up menu. (The Assistant pop-up menu is the first item to the right of the back and forward arrows in the assistant editor jump bar.)

  3. In the menu, scroll to the Preview item and choose the storyboard or xib file. 

 

iOS7 Transition Guide - 、似水流年 - youthpasses 大学里拒绝堕落

Toggle between viewing app UI in iOS 7 and iOS 6.1 or earlier. 

iOS7和iOS6.1及更早版本的UI之间的切换

 

Follow these steps to switch between two versions of the UI:

1. Open the File inspector in Interface Builder.

2. Open the “View as” menu.

3. Choose the version of the UI you want to view.

② Supporting Two Versions of a Standard App 

如果standard app的两个版本需要有类似的布局,使用Auto Layout来创建UI,这在两个版本的iOS都会显示正常。为了支持iOS的多版本,为Auto Layout指定单一约束可以在storyboard或xib文件中自动调整views和controls。

如果standard app的两个版本需要类似的布局,并且你没有使用Auto Layout,使用offsets。在iOS7中使用offsets,首先升级UI,然后为每个元素在iOS7 UI中的新位置的origin,height和width赋值。

 

③ Loading Resources Conditionally 有条件的加载资源

一种辨别app是否运行在iOS7系统或更早版本的方法是写一个宏macro,用来检测系统版本。

 


NSUInteger DeviceSystemMajorVersion();
 NSUInteger DeviceSystemMajorVersion() {                                       
     static NSUInteger _deviceSystemMajorVersion = -1;
     static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
         _deviceSystemMajorVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] intValue];                            

});

return _deviceSystemMajorVersion ;
  }                   
  #define MY_MACRO_NAME (DeviceSystemMajorVersion() <</span> 7)       


Updating the UI

① Layout and Appearance

1、试图控制器属性 wantsFullScreenLayout 被弃用,提供以下属性:

edgesForExtendedLayout: UIExtendedEdge类型,用来描述一个rectangle的四个边界,默认是UIRectEdgeAll.

extendedLayoutIncludesOpaqueBars

automaticallyAdjustsScrollViewInsets

2、iOS7中,视图控制器支持views之间自定义切换动画。见UIViewControllerAnimatorAnimatorTransitioningProtocol Reference UIViewControllerInteractiveTransitioningProtocol Reference

3、 iOS7给予视图控制器在app运行时更改状态栏风格的权限。实现:

 


appInfo.plist添加keyUIViewControllerBasedStatusBarAppearance并赋值为YES
一种动态改变状态栏风格的好方法是实现preferredStatusBarStyle,在动画块block中,更新状态栏appearance并调用setNeedsStatusBarAppearanceUpdate.
4、 你可以通过设置window的属性tintcolor设置整个app的颜色风格

 


window.tintColor = [UIColor purpleColor];//该purpleColor会按照层级自动传递给window的subviews
如果你不设置window的tintColor,app会使用系统默认颜色。但是默认颜色是nil, which means that the view uses its parent’s tint. It also means that when you ask a view for its tint color, it always returns a color value, even if you haven’t set one.(没搞明白啥意思)

Note:在iOS6中属性 tintColor 用来tint导航条、tab条、工具栏、搜索栏、scope bars的背景。在iOS7中,使用barTintColor属性来代替。

5、 iOS7使用动态风格,这可以在app中更容易的展示great-looking text。

使用UIFont的方法 preferredFontForTextStyle 来定义一个font,代替给font的names和sizes赋值的方式。

② Bars and Bar Buttons

在iOS7中,status bar是透明的(transparent),navigation bars,tab bars,toolbars,search bars 和 scope bars 是半透明的(tranlucent)。

大部分的bars模糊处理它们的背景,除非你为此bar设置了背景图片。

barPosition:如果自定义bar的背景图片需要extend,使用此属性进行描述;

UIBarPositionTopAttached 表示一个bar位于屏幕的顶部并且他的背景扩展到导航栏的区域;

UIBarPositionTop 表示一个bar位于its local context的顶部,例如,位于一个popover的顶部,并且不为状态栏提供背景。

1、The Status Bar

UIStatusBarStyleDefault 展示黑色内容,当状态栏背后是浅色内容时使用

iOS7 Transition Guide - 、似水流年 - youthpasses 大学里拒绝堕落

UIStatusBarStyleLightContent  展示浅色内容,当状态栏背后是深色内容时使用
iOS7 Transition Guide - 、似水流年 - youthpasses 大学里拒绝堕落
  有时,导航栏或者搜索栏的背景图片会扩展到状态栏的背后。
在iOS7中,你可以在app运行时控制状态栏的风格,实现方法见Updating the UI1.3。
2、Navigation Bar
iOS7 Transition Guide - 、似水流年 - youthpasses 大学里拒绝堕落
如果你想使用自定义图片代替默认的chevron,需要创建一个自定义mask image。详见 UINavigationBar Class Reference.
  如果你使用 UIBarPositionTopAttached  bar positon 或导航控制器的导航栏创建一个导航栏的背景图片,要确保 图片包含状态栏区域!特别注意,使用高为128个像素的高分辨率的背景图片!
iOS7 Transition Guide - 、似水流年 - youthpasses 大学里拒绝堕落
  不要使用特别长的背景图片来给导航条展示阴影效果,这在iOS7中不管用,因为超出的高度会扩展到状态栏区域。如果你想添加给 导航栏添加阴影,使用属性 shadowImage创建自定义背景图片。

3、Search Bar and Scope Bar

iOS7 Transition Guide - 、似水流年 - youthpasses 大学里拒绝堕落

同样如果使用UIBarPositionTopAttached 创建search bar的背景图片,要确保图片高度要包含状态栏的高度。

displaysSearchBarInNavigationBarUISearchDisplayController的属性,可让你在导航栏中添加search bar。

note:A scope bar can't appear by itself; it must be attached to a search bar.

iOS7 Transition Guide - 、似水流年 - youthpasses 大学里拒绝堕落

4、Tab Bar 

iOS7 Transition Guide - 、似水流年 - youthpasses 大学里拒绝堕落

如果你想为tab bar item创建自定义的icon,使用  UITabBarItem 的属性  selectedImage来设置item的选中状态的图片,如果你不提供 选中状态的icon,那么两种状态会使用相同的icon。
5、Toolbar
iOS7 Transition Guide - 、似水流年 - youthpasses 大学里拒绝堕落

③ Content Views
1、Activity
系统提供两种风格:
iOS7 Transition Guide - 、似水流年 - youthpasses 大学里拒绝堕落looks like  a fully rendered app icon iOS7 Transition Guide - 、似水流年 - youthpasses 大学里拒绝堕落looks similar to a bar button item
2、Collection View
iOS7支持自定义layouts转换动画,见UICollectionViewTransitionLayout Class Reference.
3、Image View
添加属性 tintColor When the image view contains a template image—that is, an image that specifies the UIImageRenderingModeAlwaysTemplate  rendering mode— tintColor  is applied to the image.
4、Map View
map view 呈现地理数据,并支持内嵌Maps app所能提供的大部分功能。
iOS7中,提供新类 MKOverlayRenderer 来在map view创建一个overlay。
为map view 添加 3D 展示效果,为map view 的属性 camera assign一个camera对象 MKMapCamera ,详情见MKMapView Class  Reference.
5、Page View Controller
使用方法  pageViewControllerPreferredInterfaceOrientationForPresentation和 pageViewControllerSupportedInterfaceOrientations 设置优选和支持的方向。
6、Scroll View

  iOS7中,可通过设置 UIViewController的属性 automaticallyAdjustsScrollViewInsets 来设置scroll view的insets。

7、Table View

8、Text View

确保使用 UIFont 的方法 preferredFontForTextStyle 来定义 text view 展示的text。

9、Web View

A web view is a region that can display rich HTML content.


④ Controls 

没啥好介绍的,都是视觉上的变化。

Note:iOS7中,UIButtonTypeRoundedRect 使用 UIButtonTypeSystem 重新定义。

⑤ Temporary Views

Note:当一个临时视图(Temporary Views)显示时,iOS7会自动模糊化后面的标准视图。你需要通过你的代码来控制这种custom views的颜色变化。

(咳咳,不是说iOS7会自动调整么,为什么还要开发者用代码控制?表示不明白。。。。)

1、Action Sheet

iOS7 不再使用 UIActionSheetStyle。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值