swift - 在操作表中显示多个图像

标签 swift image segue uialertcontroller uialertaction

目前操作表上只显示一张图像,如何让它显示两张图像? image of action sheet

@IBAction func areaAdd(_ sender: Any) {
    haptic.prepare()
    haptic.impactOccurred()

    let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)

    let areaImage = UIImage(named: "Areas")
    let area = UIAlertAction(title: "Area", style: .default, handler: { action in self.performSegue(withIdentifier: "newArea", sender: self)})
    area.setValue(areaImage?.withRenderingMode(.alwaysTemplate), forKey: "image")
    alert.addAction(area)

    let project = UIAlertAction(title: "Project", style: .default, handler: { action in self.performSegue(withIdentifier: "newProject", sender: self)})
    let projectImage = UIImage(named: "Projects")
    area.setValue(projectImage?.withRenderingMode(.alwaysTemplate), forKey: "image")
    alert.addAction(project)

    alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
    self.present(alert, animated: true, completion: nil)
}

最佳答案

@IBAction func areaAdd(_ sender: Any) { 
    let alert = UIAlertController(title: nil, message: nil,      preferredStyle: .actionSheet)
    let area = UIAlertAction(title: "Area", style: .default, handler: { action in 
        self.performSegue(withIdentifier: "newArea", sender: self)
    })
    let image = UIImage(named: "myImage")
    area.setValue(image?.withRenderingMode(.alwaysOriginal), forKey: "image")
    alert.addAction(area)
}

关于swift - 在操作表中显示多个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56189082/

相关文章:

ios - performSegueWithIdentifier 给出运行时错误,为什么?

ios - 在 Vine Sign Up 等 View Controller 之间创建流畅的 Gif Segue

ios - Objective-c和Swift混合项目-Swift.h文件报错

objective-c - UIAlertController 延迟显示

html - 使背景图像响应

image - Julia - 如何使用函数 `imshow` 调整图像大小?

swift - 当核心数据中没有找到相关实体时,无法识别的选择器发送到实例

swift - 无法构建 ScanApiSdk 并出现错误 ScanApiHelper.h 文件未找到

javascript - 是否有一个 js 库可以以最佳间距以行显示图像搜索结果?

ios - App Store 应用程序使用什么样的 segue?