2016-04-22 35 views
0

如何在制作动画时让UIImageView超出其他子视图/ UIImageView?请检查白王在画面动画时将UIImageView放到前面

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

回答

2
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 

        } 
+0

工作,谢谢。 – phuong

1

如果piece是你UIImageView要在它的兄弟姐妹面前,用途:完美

piece.superview?.bringSubviewToFront(piece) 
+0

当我将ImageView添加到主板时,我确实把它带到了前面。但似乎在触发动画之前我需要再次将它带到前面。 – phuong

+0

可能是因为其他项目后来添加了,后来的项目总是在前面的项目前面。 – vacawama

+0

是的,感谢您的信息 – phuong