【问题标题】:Get the size of a UIAlertAction获取 UIAlertAction 的大小
【发布时间】:2019-02-13 20:02:53
【问题描述】:

有没有办法从UIAlertAction 获取高度/宽度?​​

它似乎不是UIView 的子类,那么在UIAlertController 中是否为它设置了一个常量?

【问题讨论】:

  • 你真正想做什么? UIAlertController 无法自定义。
  • 我想确定它的高度来计算视图中其他对象的大小。关于如何获得这个的任何想法?

标签: ios cocoa-touch uialertcontroller uialertaction


【解决方案1】:

是的,您可以通过

获取 UIAlertController 的高度/宽度
present(alertController, animated: true, completion: nil)
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
    alertController.view.frame.height
}

注意:需要在当前 UIAlertController 之后放置一些延迟 You will get alert part frame only

【讨论】:

  • 这是否只返回整个视图的警报部分(包括警报下的变暗部分)?
猜你喜欢
  • 2016-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-05
  • 1970-01-01
  • 1970-01-01
  • 2014-09-23
  • 2012-06-21
  • 2018-05-01
相关资源
最近更新 更多