phuong phuong - 7 months ago 33
Swift Question

Bring UIImageView to front while animating

How can we make an UIImageView to go over/above other subview/UIImageView while animating? Please check the white king in the picture

UIView.animateWithDuration(3, animations:{
self.squares[moveInfo.start.0][moveInfo.start.1].occupyingPieceImageView.frame =
self.squares[moveInfo.end.0][moveInfo.end.1].frame

}


see the white king

Answer
UIView.animateWithDuration(3, animations:{
                    self.view.bringSubViewToFront(self.squares[moveInfo.start.0][moveInfo.start.1].occupyingPieceImageView)                  
                    self.squares[moveInfo.start.0][moveInfo.start.1].occupyingPieceImageView.frame =
                    self.squares[moveInfo.end.0][moveInfo.end.1].frame

                    }