I have a UIImageView called draggableImageView that is a subview of a UIView called tiltedView that is tilted backwards via CATransform3DRotate and with perspective transform.m34 = -1 / 400.0. That way, when I drag draggableImageView around, its perspective and absolute size change so that it appears to be moving in 2-space within the tiltedView.
I would like to calculate the frame for draggableImageView within tiltedView but using a different coordinate system (in this case, a UIView called viewForCoordinates that is not tilted and encompasses the whole screen). However, using [self convertRect:self.frame toView:self.viewForCoordinates] from within draggableImageView outputs the same sized frame regardless of where within tiltedView my draggableImageView is located.
I figure using self.frame is more appropriate than self.bounds since bounds is agnostic to the superview while frame is dependent upon it. However, based upon the above, I’m guessing that convertRect is just converting self.frame agnostic of the perspective manipulation applied to self.frame‘s superview’s.
I’m not sure what code would be helpful in this case, so please let me know what code I can provide to help get this question answered.
I solved this!
So I think there were two main issues:
1) When
DraggableImageViewobject is touched, make sure object is indeed being touched viaif ([touch view] == self)within- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event2) Convert touch location to
superviewcoordinate system viaself.touchLocation = [[touches anyObject] locationInView:self.superview].3) Convert
DraggableImageView‘s frame fromsuperviewcoordinate toviewForCoordinatescoordinate system. <<< I think my error was that I converted fromselfrather thansuperview.4) If making changes to
DraggableImageView‘s frame or location based onviewForCoordinates, calculate changes withinviewForCoordinates‘s coordinate systemm and then convert back toDraggableImageView‘ssuperview. <<< I think I forgot to do this conversion :S