将 progressView 移动到屏幕底部?

Move progressView to bottom of screen?

我在屏幕上添加了一个进度条,目前已将其置于屏幕中央。相反,我希望它在我的容器中水平居中,但在屏幕底部。 (如果我用 CGPoint 写,我会让它说 y: self.frame.midY-250)。如何编辑第三行使其居中 x,但更改其 y 位置?

func addControls() {
    progressView = UIProgressView(progressViewStyle: 
    UIProgressViewStyle.Default)
    progressView?.center = self.view.center
    view.addSubview(progressView!)
}

你自己的问题已经有了大部分答案。

let pos = CGPoint(x: self.view.bounds.midX, y: self.view.bounds.maxY - 250)
progressView?.center = pos

250 更改为距离您希望进度视图的底部有多远。

但是最好使用约束来设置进度视图的大小和位置。如果设备旋转并且其超级视图大小发生变化,这将确保进度视图保持在正确的位置。