【发布时间】:2018-12-04 20:55:48
【问题描述】:
我正在尝试以编程方式将活动指示器集中在警报控制器中,但没有看到预期的结果。
尝试:
import NVActivityIndicatorView
public func displayActivityAlertWithCompletion(ViewController: UIViewController, pending: UIAlertController, completionHandler: @escaping ()->())
{
//create an activity indicator
let indicator = NVActivityIndicatorView(frame: CGRect(x: (pending.view.frame.width/2) - 25 , y: 0, width: 50, height: 50))
//indicator.clipsToBounds = true
indicator.type = .ballScaleMultiple
indicator.autoresizingMask = \[.flexibleWidth, .flexibleHeight\]
indicator.color = UIColor(rgba: Palette.loadingColour)
//add the activity indicator as a subview of the alert controller's view
pending.view.addSubview(indicator)
indicator.isUserInteractionEnabled = false
// required otherwise if there buttons in the UIAlertController you will not be able to press them
indicator.startAnimating()
ViewController.present(pending, animated: true, completion: completionHandler)
}
【问题讨论】:
-
你在看什么?
-
@MilanNosáľ 抱歉,我添加了一张图片,但代码的语法搞砸了,重新添加它
-
您从这个
pending.view.frame.width获得了什么价值?从哪里调用方法displayActivityAlertWithCompletion?
标签: ios swift uiview constraints autoresizingmask