好久没有写文章,今天刚拿到iphone6s手机,写个demo ,如题
1.先用Xcode7.0新建一个项目,在plist里面 source code追加:
<key>UIApplicationShortcutItems</key>
<array>
<dict>
<key>UIApplicationShortcutItemIconType</key>
<string>UIApplicationShortcutIconTypePlay</string>
<key>UIApplicationShortcutItemType</key>
<string>modelId1</string>
<key>UIApplicationShortcutItemTitle</key>
<string>播放</string>
</dict>
<dict>
<key>UIApplicationShortcutItemIconType</key>
<string>UIApplicationShortcutIconTypeAdd</string>
<key>UIApplicationShortcutItemType</key>
<string>modelId2</string>
<key>UIApplicationShortcutItemTitle</key>
<string>添加</string>
</dict>
</array>
或者如图:
2.在appdelegate文件加入:
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL))completionHandler
{
if([shortcutItem.type isEqualToString:@"modelId1"]){
//ToDo 业务逻辑
}
}
如图:
3.别的我不说了,running
效果图如下:
ps: popview里面的图标是可以自定义的,毕竟系统太丑了