Created
October 27, 2015 05:27
-
-
Save y8k/b691fb0964a8944cb495 to your computer and use it in GitHub Desktop.
Implementation Preview Actions for 3D touch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func previewActionItems() -> [UIPreviewActionItem] { | |
let safariAction = UIPreviewAction(title: "Open with Safari", style: UIPreviewActionStyle.Default) { (action, viewCntrlr) -> Void in | |
UIApplication.sharedApplication().openURL(NSURL(string: "http://y8k.me")!) | |
} | |
let closeAction = UIPreviewAction(title: "Copy URL", style: .Default) { (action, viewCntrlr) -> Void in | |
UIPasteboard.generalPasteboard().string = "http://y8k.me" | |
} | |
let action1 = UIPreviewAction(title: "Action1", style: .Default) { (action, vc) -> Void in | |
print("action1") | |
} | |
let action2 = UIPreviewAction(title: "Action2", style: .Default) { (action, vc) -> Void in | |
print("action2") | |
} | |
let action3 = UIPreviewAction(title: "Action3", style: .Default) { (action, vc) -> Void in | |
print("action3") | |
} | |
let actionGroup = UIPreviewActionGroup(title: "Actions", style: UIPreviewActionStyle.Default, actions: [action1, action2, action3]) | |
return [safariAction, closeAction, actionGroup] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment