简体   繁体   中英

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

                    }

见白国王

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

                    }

如果piece是您要位于其兄弟姐妹前面的UIImageView ,请使用:

piece.superview?.bringSubviewToFront(piece)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM