AnimateWithDuration 块不正确

AnimateWithDuration block is not correct

我正在尝试使用 AnimateWithDuration 块为 UIView 制作动画。这个 UIView 包含两个 UIScrollViews 和两个按钮。一个按钮是向下过滤,另一个是向上过滤。喜欢图片:

所以向下滚动我使用这个块:

@IBAction func FilterEntry(sender: AnyObject) {

    self.FilterDown.hidden = true
    self.FilterDownIcon.hidden = true

    var duration = 0.5
    UIView.animateWithDuration(duration, animations: {
        self.ColouredSquare.frame = CGRect(x: 0, y: 65, width: 400, height: 212)

        }, completion: { finished in
            self.FilterUPIcon.hidden = true
            self.FilterUP.hidden = true
            self.DateScroll.hidden = false
            self.EventScroll.hidden = false
            self.FilterUPIcon.hidden = false
            self.FilterUP.hidden = false
     })
}

效果很好,滚动效果很好。但是当我走另一条路时,UIView 上升,然后 UIView 上升正常,但是 UIScollviews 的移除一直持续到动画结束然后消失。我可以通过代码看到这是有道理的,但是当它下降时它运行平稳但上升时看起来很可怕。

这是我启动 UIView 的代码:

 @IBAction func FilterUPEvent(sender: AnyObject) {

        self.FilterUP.hidden = true
        self.FilterUPIcon.hidden = true

        var duration = 0.5
        UIView.animateWithDuration(duration, animations: {
            self.ColouredSquare.frame = CGRect(x: 0, y: 65, width: 400, height: 20)

            }, completion: { finished in

                self.EventScroll.hidden = true
                self.DateScroll.hidden = true
                self.FilterUP.hidden = true
                self.FilterUPIcon.hidden = true
                self.FilterDown.hidden = false
                self.FilterDownIcon.hidden = false
        })
 }

尝试在动画块上方设置 self.colouredSquare.clipToBounds = true

clipToBounds is a Boolean value that determines whether subviews are confined to the bounds of the view. Setting this value to true causes subviews to be clipped to the bounds of the receiver. If set to false, subviews whose frames extend beyond the visible bounds of the receiver are not clipped. The default value is false.