带白色边框的alertController

时间:2017-06-23 10:33:10

标签: ios swift uialertcontroller

我创建了一个带有操作表和两个按钮的alertcontroller。由于动作表将具有圆形边缘,在屏幕上,在四个角上,出现白色。我尝试更改alertcontroller的背景颜色,但这使得操作表变为带有尖锐边框而不是圆形边框的矩形。我尝试将视图背景颜色设置为清除颜色 尝试设置边框半径。 这是我的行动表。我希望那些白边看不见。

enter image description here

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

Caused by: java.lang.ClassCastException: scala.Tuple2 cannot be cast to org.apache.spark.graphx.Edge
  at org.apache.spark.graphx.EdgeRDD$$anonfun$1$$anonfun$apply$1.apply(EdgeRDD.scala:107)
  at scala.collection.Iterator$class.foreach(Iterator.scala:893)
  at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
  at org.apache.spark.graphx.EdgeRDD$$anonfun$1.apply(EdgeRDD.scala:107)
  at org.apache.spark.graphx.EdgeRDD$$anonfun$1.apply(EdgeRDD.scala:105)
  at org.apache.spark.rdd.RDD$$anonfun$mapPartitionsWithIndex$1$$anonfun$apply$26.apply(RDD.scala:844)
  at org.apache.spark.rdd.RDD$$anonfun$mapPartitionsWithIndex$1$$anonfun$apply$26.apply(RDD.scala:844)
  at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:38)
  at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:323)
  at org.apache.spark.rdd.RDD.iterator(RDD.scala:287)
  at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:38)
  at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:323)
  at org.apache.spark.rdd.RDD$$anonfun$8.apply(RDD.scala:336)
  at org.apache.spark.rdd.RDD$$anonfun$8.apply(RDD.scala:334)
  at org.apache.spark.storage.BlockManager$$anonfun$doPutIterator$1.apply(BlockManager.scala:1005)
  at org.apache.spark.storage.BlockManager$$anonfun$doPutIterator$1.apply(BlockManager.scala:996)
  at org.apache.spark.storage.BlockManager.doPut(BlockManager.scala:936)
  at org.apache.spark.storage.BlockManager.doPutIterator(BlockManager.scala:996)
  at org.apache.spark.storage.BlockManager.getOrElseUpdate(BlockManager.scala:700)
  at org.apache.spark.rdd.RDD.getOrCompute(RDD.scala:334)
  at org.apache.spark.rdd.RDD.iterator(RDD.scala:285)
  at org.apache.spark.graphx.EdgeRDD.compute(EdgeRDD.scala:50)
  at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:323)
  at org.apache.spark.rdd.RDD.iterator(RDD.scala:287)
  at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
  at org.apache.spark.scheduler.Task.run(Task.scala:99)
  at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:322)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)

编辑 - 1:为alertcontroller添加代码

let cancelAction = UIAlertAction(title: "Cancel".localize(), style: .cancel) { _ in
    // this is where I am creating the cancelAction
}

1 个答案:

答案 0 :(得分:1)

此处是此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:https://github.com/BhaveshDhaduk/AlertControllerSwift

enter image description here