Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 带白色边框的alertController_Ios_Swift_Uialertcontroller - Fatal编程技术网

Ios 带白色边框的alertController

Ios 带白色边框的alertController,ios,swift,uialertcontroller,Ios,Swift,Uialertcontroller,我已经创建了一个带有操作表和两个按钮的alertcontroller。由于操作表将具有圆形边缘,因此在屏幕上的四个角上会出现白色。我尝试更改alertcontroller的背景色,但这会使动作表变成带有锐利边框的矩形,而不是圆形边框。我尝试将视图背景色设置为“清除颜色” 也尝试设置边界半径。 这是我的行动表。我想要看不见的白色边缘 另外,如何更改取消的背景色 let cancelAction = UIAlertAction(title: "Cancel".localize(), style:

我已经创建了一个带有操作表和两个按钮的alertcontroller。由于操作表将具有圆形边缘,因此在屏幕上的四个角上会出现白色。我尝试更改alertcontroller的背景色,但这会使动作表变成带有锐利边框的矩形,而不是圆形边框。我尝试将视图背景色设置为“清除颜色” 也尝试设置边界半径。 这是我的行动表。我想要看不见的白色边缘

另外,如何更改取消的背景色

let cancelAction = UIAlertAction(title: "Cancel".localize(), style: .cancel) { _ in
    // this is where I am creating the cancelAction
}
编辑-1:为alertcontroller添加代码

func showActionSheet(_ changeAction: UIAlertAction) {
    let alertController = UIAlertController(title: "", message: "Here is my alert text".localize(), preferredStyle: .actionSheet)

    alertController.view.tintColor = StyleKit.goldenColor
    let attributedString = NSAttributedString(string: alertController.message!, attributes: [
        NSForegroundColorAttributeName : StyleKit.whiteColor
        ])
    alertController.setValue(attributedString, forKey: "attributedMessage")
    if let subview = alertController.view.subviews.first, let alertContentView = subview.subviews.first {
        for innerView in alertContentView.subviews {
            innerView.backgroundColor = StyleKit.popoverDefaultBackgroundColor

        }

    }
    let cancelAction = UIAlertAction(title: "Cancel".localize(), style: .cancel) { _ in
        self.doneButton.isEnabled = true
    }

    alertController.addAction(changeAction)
    alertController.addAction(cancelAction)
    self.present(alertController, animated: true)
}

以下是
UIAlertAction
actionSheet

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

if let subview = actionSheet.view.subviews.first, let actionSheet = subview.subviews.first {
    for innerView in actionSheet.subviews {
        innerView.backgroundColor = .purple
        innerView.layer.cornerRadius = 15.0
        innerView.clipsToBounds = true
    }
}

actionSheet.addAction(UIAlertAction.init(title: "Take Photo", style: UIAlertActionStyle.default, handler: { (action) in

}))
actionSheet.addAction(UIAlertAction.init(title: "Choose Photo", style: UIAlertActionStyle.default, handler: { (action) in

}))
actionSheet.addAction(UIAlertAction.init(title: "Cancel", style: UIAlertActionStyle.cancel, handler: { (action) in
}))

actionSheet.view.tintColor = .orange

self.present(actionSheet, animated: true, completion: nil)
使用十六进制颜色更新

Github:


为您编写的alertController添加代码。请检查我的编辑@iOSDevBoth将更改背景颜色(您以紫色给出)。由于最后一个和第一个都在更改“拍照并选择照片”的背景色,因此修复程序不起作用。不是边界线。这是我一直用的颜色。UIColor(十六进制:“0D324E”)对我有用,首先是唯一的部分:innerView.layer.cornerRadius=15.0只需更改操作表的收音机,检查此项,同时我将使用您提供的hax颜色进行检查。我不知道为什么此修复在我的代码中不起作用。但是你的代码是完美的。我试过其他样品。你知道如何改变取消按钮的背景色吗?