带有白色边框的alertController

我创build了一个带有操作表和两个button的alertcontroller。 由于操作单将具有圆angular的边缘,在屏幕上的四个angular上出现白色。 我试着改变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的这个白色边框的解决scheme

 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) 

用hex颜色更新

Github: https : //github.com/BhaveshDhaduk/AlertControllerSwift

在这里输入图像说明