发布集中活动指标

时间:2017-02-27 22:46:26

标签: ios xcode swift3 subview uiactivityindicatorview

我在子视图中以活动指示器视图为中心存在问题,我不确定原因。它正确加载,只是不确定它为什么不在子视图中居中...提前感谢!

controlsContainerView.frame = frame         addSubview(controlsContainerView)

    controlsContainerView.addSubview(activityIndicatorView)
    activityIndicatorView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
    activityIndicatorView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true

1 个答案:

答案 0 :(得分:1)

centerXAnchor是视图的属性。我们不清楚代码的equalTo部分中的视图:

activityIndicatorView.centerXAnchor.constraint(equalTo:centerXAnchor).isActive = true

尝试明确命名视图:

activityIndicatorView.centerXAnchor.constraint(equalTo: containerView.centerXAnchor)
.isActive = true