3d touch 的使用(一)
废话不多说,直接上代码------------------
在
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
方法里面判断,该手机是否是9.0以上,因为3dtouch是9.0以后出的功能
CGFloat currentDeviceVersionFloat = [[[UIDevice currentDevice] systemVersion] floatValue];
//判断版本号,3D Touch是从iOS9.0后开始使用
if (currentDeviceVersionFloat >= 9.0) {
[self addThreeDTouchAction:application]; // 在此方法里面添加3d touch 桌面cell
}
- (void)addThreeDTouchAction:(UIApplication *)application{
UIApplicationShortcutIcon *sys = [UIApplicationShortcutIcon iconWithType:<#(UIApplicationShortcutIconType)#>];// 使用此方法,可以调用系统默认的图标
//以下为自定义
UIApplicationShortcutIcon *iconLottery = [UIApplicationShortcutIcon iconWithTemplateImageName:@"server_lottery"];
/// 3d touch开奖大厅 按钮创建
UIMutableApplicationShortcutItem *itemLottery = [[UIMutableApplicationShortcutItem alloc] initWithType:ThreeDTouchTypeLottery localizedTitle:@"开奖大厅"];// 指定标题
itemLottery.icon = iconLottery; // 指定图标
itemLottery.localizedSubtitle = @"开奖全网最快";// 指定子标题
UIApplicationShortcutIcon *iconGold = [UIApplicationShortcutIcon iconWithTemplateImageName:@"server_gold"];
/// 3d touch开奖大厅 按钮创建
UIMutableApplicationShortcutItem *itemGold = [[UIMutableApplicationShortcutItem alloc] initWithType:ThreeDTouchTypeGold localizedTitle:@"比分赛果"];
itemGold.icon = iconGold;
itemGold.localizedSubtitle = @"比分信息最全";
/// 3d touch开奖大厅 按钮创建
UIApplicationShortcutIcon *iconFriend = [UIApplicationShortcutIcon iconWithTemplateImageName:@"tabbar_find_normal"];
UIMutableApplicationShortcutItem *itemFriend = [[UIMutableApplicationShortcutItem alloc] initWithType:ThreeDTouchTypeFriend localizedTitle:@"身边彩友"];
itemFriend.icon = iconFriend;
itemFriend.localizedSubtitle = @"寻找身边的彩友";
application.shortcutItems = @[itemLottery,itemGold,itemFriend];
}
// 在此方法里面添加你的操作
- (void)application:(UIApplication *)application performActionForShortcutItem:(nonnull UIApplicationShortcutItem *)shortcutItem completionHandler:(nonnull void (^)(BOOL))completionHandler;
注:
// 当项目上线,系统会默认添加分享的功能
// UIApplicationShortcutIconType 的类型校对表
最新文章
- BOM以及定时器
- Color Transfer between Images code实现
- 内置对象session ,cookic,Application,ViewState
- linux下设置固定IP
- 关于ssh调用远程后台命令挂住的解释
- 不同版本CUDA编程的问题
- 关于全局唯一ID生成方法
- Medusa: Gauges for JavaFX
- Androidstudio 点9图报错的问题
- 如果利用storyboard创建cell中标识符identifier的正确设置
- Windows使用WxWidgets开发界面(c++)环境搭建
- JDK动态代理机制
- nginx错误:unknown directive ";锘? in F:\nginx/conf/nginx.conf:3
- javaMail邮件发送的简单实现
- 启动aspx文件错误
- $Django Rest Framework-认证组件,权限组件 知识点回顾choices,on_delete
- LeetCode(88):合并两个有序数组
- cmd返回上一级和根目录
- JavaScript 神奇的参数
- InfluxDB(官方使用说明)
热门文章
- 利用JavaScript制作简易日历
- ACM___数学___九的余数
- 为什么在JavaScript中0.1+0.2不等于0.3?
- django rest-farme-work 的使用(1)
- springboot 不使用前端模板直接跳转页面
- 四大MQ比较及MQ详解
- win7下UDL文件不同
- redis 对 key 的操作
- SpringMVC-HandlerMapping和HandlerAdapter
- ZOJ 3888 Twelves Monkeys