UIAlertController .actionSheet dividers between items are not the same

Viewed 398

I created UIAlertController with different actions. Here is the code:

typealias OptionMenuItem = (title: String, style: UIAlertAction.Style, handler: () -> Void)
@discardableResult func showOptionsAlert(items: [OptionMenuItem]) -> UIAlertController {
        let alertController = UIAlertController(title: nil, message: nil,
                preferredStyle: UIAlertController.Style.actionSheet)

        items.forEach({it in
            alertController.addAction(UIAlertAction(title: it.title, style: it.style, handler: {_ in
                it.handler()
            }))
        })

        present(alertController, animated: true, completion: nil)
        return alertController
    }


showOptionsAlert(items: [
            ("Copy Link", .default, {}),
            ("Turn On Post Notifications", .default, {}),
            ("Report", .destructive, {}),
            ("Mute", .destructive, {}),
            ("Unfollow", .destructive, {}),
            ("Cancel", .cancel, {})
        ])

As a result I got this enter image description here

The dividers between alert items are different. How to make them the same?

1 Answers

As far as I can see from the image above, under the sheet your background is not uniform, and as far as I can guess it changes its color right above the divider for which you claim to be different. So it looks like that your background is different.

Related