3

I wonder if there is any way of adding an icon to the quick actions associated with a peek & pop preview (reachable through 3D touch).

I have created a couple of preview actions using:

UIPreviewAction(title: "Save".localized, style: .Default)

but I fail o find a way of adding any type of icon or image to the buttons making them more understandable.

https://i.stack.imgur.com/qgtE5.png

Example: The second row has an icon (photoshopped) as I want it.

1 Answers1

0

You can add trailing icon for your action:

extension UIPreviewAction {

private var imageKey: String {
    return "image"
}

var actionImage: UIImage? {
    get {
        if self.responds(to: Selector(imageKey)) {
            return self.value(forKey: imageKey) as? UIImage
        }
        return nil
    }
    set {
        if self.responds(to: Selector(imageKey)) {
            self.setValue(newValue, forKey: imageKey)
        }
    }
}
}

How to use:

yourAction.actionImage = UIImage(named: "somePicture")
zslavman
  • 401
  • 5
  • 11