我创建了带有不同操作的UIAlertController。以下是代码:
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, {})
])
作为结果,我得到了这个 警报项之间的分隔符不同。如何使它们相同?