我在子视图中以活动指示器视图为中心存在问题,我不确定原因。它正确加载,只是不确定它为什么不在子视图中居中...提前感谢!
controlsContainerView.frame = frame addSubview(controlsContainerView)
controlsContainerView.addSubview(activityIndicatorView)
activityIndicatorView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
activityIndicatorView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
答案 0 :(得分:1)
centerXAnchor
是视图的属性。我们不清楚代码的equalTo
部分中的视图:
activityIndicatorView.centerXAnchor.constraint(equalTo:centerXAnchor).isActive = true
尝试明确命名视图:
activityIndicatorView.centerXAnchor.constraint(equalTo: containerView.centerXAnchor)
.isActive = true