I have a view which has two UIImageViews
. The bottom holds an image which is a photo taken/selected by the user.
The top holds an image semi transparent with a transparent circle. The top UIImageView
can be moved by a gesture pan.
When the VC viewDidAppear
I calculate some ratios of the image and find the bottom image's new frame. I also find the center point of the top view that is moved.
With this center point I calculate where the center point would be on the original image size. When the device is then rotated, I re-calculate the sizes/ratios. I am now trying to update the top image views position on screen based on the new calculations. From my logs I see the values appear to be correct, but the view does not move as expected. No move occurs.
float newX = self.centerPointOnOriginalImage.x * self.scaleDownOriginalImageRatio;
float newY = self.centerPointOnOriginalImage.y * self.scaleDownOriginalImageRatio;
NSLog(@"The new center point for the photo mask view is: %@",NSStringFromCGPoint(CGPointMake(newX, newY)));
self.photoMaskView.center = CGPointMake(newX, newY);
// Find out how to move a view with transform here as the view is not moving as expected
NSLog(@"The view was moved to here: Center: %@",NSStringFromCGPoint(self.photoMaskView.center));
Do I need to move the top UIImageView
(self.photoMaskView.center
) center point with a CGAffineTransform to actually make the view move, if so how do I do this?
Putting the move of the center point in the viewDidLayoutSubviews
worked.