ios - Animate UIImageView from a subview to parent view -
i'm working on project allowing users play chess. have parent view represents board, each square added board subview. chess piece uiimageview , added square subview.
occupyingpieceimageview = uiimageview(frame: cgrectmake(0, 0, size, size)) self.addsubview(occupyingpieceimageview)
to animate chess move want change position of piece 1 square other, understand means changing uiimageview's frame don't know how, frame within it's parent view (square). doesn't work:
func move(destsquare: square){ var imgview = self.occupyingpieceimageview var thispiece = self.piece uiview.animatewithduration(3, animations: { self.clearpiece() imgview.frame = destsquare.frame }) destsquare.setpiece(thispiece) }
consider adding pieces board rather squares. architecture allow animate movement, including placing piece on line between 2 squares.
Comments
Post a Comment