我创建了一个带有操作表和两个按钮的警报控制器。由于操作表将具有圆形边缘,因此在屏幕上的四个角上会出现白色。我尝试更改警报控制器的背景颜色,但这使操作表成为具有锐边边框而不是圆形边框的矩形。我尝试将视图背景颜色设置为清晰颜色也尝试设置边框半径。这是我的行动表。我希望这些白色边缘不可见。
另外,如何更改取消的背景颜色。
let cancelAction = UIAlertAction(title: "Cancel".localize(), style: .cancel) { _ in
// this is where I am creating the cancelAction
}
Run Code Online (Sandbox Code Playgroud)
编辑 - 1:添加警报控制器代码
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
}
} …Run Code Online (Sandbox Code Playgroud)