Ios UIView混乱

Ios UIView混乱,ios,swift,uiview,Ios,Swift,Uiview,总之,我试图找出一个UIView,它通过以下代码变得更大: ColouredSquare.backgroundColor = UIColor(red: 0.84, green: 0.90, blue: 0.95, alpha: 1.0) ColouredSquare.frame = CGRect(x: 0, y:50, width: 400, height: 30) self.view.addSubview(ColouredSquare) UIView.animateW

总之,我试图找出一个UIView,它通过以下代码变得更大:

 ColouredSquare.backgroundColor = UIColor(red: 0.84, green: 0.90, blue: 0.95, alpha: 1.0)
    ColouredSquare.frame = CGRect(x: 0, y:50, width: 400, height: 30)
    self.view.addSubview(ColouredSquare)
    UIView.animateWithDuration(1.0, animations: {
        self.ColouredSquare.frame = CGRect(x: 0, y: 50, width: 400, height: 180)
    })
我在视图中添加了一个按钮。 但是按钮在UIView之前绘制


我是否遗漏了一些明显的东西

您可以设置框架:

ColouredSquare.frame = CGRect(x: 0, y:50, width: 400, height: 30)
然后设置动画,将高度增加到180:

self.ColouredSquare.frame = CGRect(x: 0, y: 50, width: 400, height: 180)

coloredsquare
实例将更大,但无法告诉您该视图在视图层次结构的这个小片段中的位置。也许您需要检查视图和代码之间的出口连接。。。