3D Touch

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

在主界面,開發者可以在手機支持3D Touch時候(目前6S,6S plus)自定義shortcutItem(快捷鍵),如圖所示:

微信快捷鍵
微信快捷鍵
@Class  UIApplicationShortcutItem  
@property  type,localizedTitle,localizedSubtitle,UIApplicationShortcutIcon,userInfo

主要由Item類型,主標題,副標題還有圖標,還可以添加一些附加信息。但是數量上有一定得限制。

Icon UIApplicationShortcutIcon

  1. 系統:UIApplicationShortcutIconType
  2. 自定義:當然得滿足 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)渲染處理時候系統會忽略顏色,并創建基于圖像模板的a值(小于 1.0)

Changing Your App’s Dynamic Quick Actions:

  • 靜態方式在 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出整個界面。

注冊預覽功能代理,實現Peek 和 Pop

[self registerForPreviewingWithDelegate:self sourceView:self.view];

代理需要接受 UIViewControllerPreviewingDelegate 協議,

//可以自定義彈出視圖的內容,大小,在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);

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容