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
- 系统: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)渲染处理时候系统会忽略颜色,并创建基于图像模板的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);