0

I am implementing 3D Touch Peek and pop preview actions in my application.

Here is what I have in my ViewController that gets used for the peek and pop.

var previewActions: [UIPreviewAction] {

    let item1 = UIPreviewAction(title: "Item1", style: .default) { (action, vc) in
     // run item 1 action
    }

    let item2 = UIPreviewAction(title: "Item2", style: .destructive) { (action, vc) in
     // run item 2 action
    }

    return [item1, item2]
}

The actions are working correctly but the destructive action (item 2) is not displaying the title in red, its still blue.

How can I get the title to display in red like the apple photos app does for the delete button?

I thought the behaviour is the same as UIAlertControllers where destructive is red.

crashoverride777
  • 10,581
  • 2
  • 32
  • 56

1 Answers1

1

Try to use UIPreviewActionItem instead.

@available(iOS 9.0, *)
override var previewActionItems: [UIPreviewActionItem] {

    let item1 = UIPreviewAction(title: "Item1", style: .default) {
        (action, vc) in
        // run item 1 action
    }

    let item2 = UIPreviewAction(title: "Item2", style: .destructive) {
        (action, vc) in
        // run item 2 action
    }

    return [item1, item2]
}
Kevin Hsia
  • 26
  • 1
  • Thank you very much, this is working. I am still having issues using preview Actions in my SpriteKit game (messes up Physics) but thats for another question. Thanks again – crashoverride777 Oct 29 '16 at 10:43