Xcode 7.0 && IOS 9
3D Touch developer 猛戳這里
Pressure Sensitivity
IOS9.0升級的 備忘錄無疑是一大亮點!高大上得繪圖功能,當然結合 3D Touch,產生了新的玩法叶眉,壓力大小可改變畫筆粗細。
UITouch (The force of a touch is available starting in iOS 9 on devices that support 3D Touch.)
// Force of the touch, where 1.0 represents the force of an average touch
@property(nonatomic,readonly) CGFloat force NS_AVAILABLE_IOS(9_0);
// Maximum possible force with this input mechanism
@property(nonatomic,readonly) CGFloat maximumPossibleForce NS_AVAILABLE_IOS(9_0);
// UIForceTouchCapability 檢測是否支持壓力感應
Quick Actions
在主界面眨层,開發(fā)者可以在手機支持3D Touch時候(目前6S匣距,6S plus)自定義shortcutItem(快捷鍵)面哥,如圖所示:
@Class UIApplicationShortcutItem
@property type,localizedTitle,localizedSubtitle,UIApplicationShortcutIcon,userInfo
主要由Item類型,主標題毅待,副標題還有圖標尚卫,還可以添加一些附加信息。但是數(shù)量上有一定得限制尸红。
Icon UIApplicationShortcutIcon
- 系統(tǒng):UIApplicationShortcutIconType
- 自定義:當然得滿足 loaded from the app's bundle吱涉, system-defined icon style。
Icons should be square, single color, and 35x35 points, as shown in these template files and as described in Template Images in UIKit User Interface Catalog and in iOS Human Interface Guidelines.(正方形外里,單色怎爵,35*35)渲染處理時候系統(tǒng)會忽略顏色,并創(chuàng)建基于圖像模板的a值(小于 1.0)
Changing Your App’s Dynamic Quick Actions:
- 靜態(tài)方式在 info.plist UIApplicationShortcutItems中添加字段
- Dynamic 自定義且能夠更改plist中預設的字段
AppDelegate 添加快捷鍵的時候的處理:
// Called when the user activates your application by selecting a shortcut on the home screen,
// except when -application:willFinishLaunchingWithOptions: or -application:didFinishLaunchingWithOptions returns NO.
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void(^)(BOOL succeeded))completionHandler NS_AVAILABLE_IOS(9_0);
Peek Pop
個人感覺這個功能還是比較酷炫盅蝗,顛覆交互習慣的方式鳖链。Peek,只需要輕壓就可以preview快速預覽墩莫,當然可以當前選擇項的更多的內容芙委,信息的內容,郵件的詳情狂秦。Peek quick actions 灌侣,當然,如果你覺得這個內容可以迅速的進行處理故痊,我們便能夠在peek之后進行一個快速的處理(標為已讀顶瞳,回復,等)愕秫,最后當你覺得可以進一步處理這個Item時慨菱,便可以再加點壓力,則會Pop出整個界面戴甩。
注冊預覽功能代理符喝,實現(xiàn)Peek 和 Pop
[self registerForPreviewingWithDelegate:self sourceView:self.view];
代理需要接受 UIViewControllerPreviewingDelegate 協(xié)議,
//可以自定義彈出視圖的內容甜孤,大小协饲,在Pop出來時是以 UINavigationController 為背景!
- (nullable UIViewController *)previewingContext:(id <UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location NS_AVAILABLE_IOS(9_0);
- (void)previewingContext:(id <UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit NS_AVAILABLE_IOS(9_0);