废话不多说,直接上代码------------------

- (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 的类型校对表

最新文章

  1. BOM以及定时器
  2. Color Transfer between Images code实现
  3. 内置对象session ,cookic,Application,ViewState
  4. linux下设置固定IP
  5. 关于ssh调用远程后台命令挂住的解释
  6. 不同版本CUDA编程的问题
  7. 关于全局唯一ID生成方法
  8. Medusa: Gauges for JavaFX
  9. Androidstudio 点9图报错的问题
  10. 如果利用storyboard创建cell中标识符identifier的正确设置
  11. Windows使用WxWidgets开发界面(c++)环境搭建
  12. JDK动态代理机制
  13. nginx错误:unknown directive &quot;锘? in F:\nginx/conf/nginx.conf:3
  14. javaMail邮件发送的简单实现
  15. 启动aspx文件错误
  16. $Django Rest Framework-认证组件,权限组件 知识点回顾choices,on_delete
  17. LeetCode(88):合并两个有序数组
  18. cmd返回上一级和根目录
  19. JavaScript 神奇的参数
  20. InfluxDB(官方使用说明)

热门文章

  1. 利用JavaScript制作简易日历
  2. ACM___数学___九的余数
  3. 为什么在JavaScript中0.1+0.2不等于0.3?
  4. django rest-farme-work 的使用(1)
  5. springboot 不使用前端模板直接跳转页面
  6. 四大MQ比较及MQ详解
  7. win7下UDL文件不同
  8. redis 对 key 的操作
  9. SpringMVC-HandlerMapping和HandlerAdapter
  10. ZOJ 3888 Twelves Monkeys