I am having a problem when using CGAffineTransformMakeTranslation on iOS7. The view I am using the CGAffineTransformMakeTranslation is going to a different position when running iOS7 and iOS8. Why is this and what am I doing wrong?
I have a view that I am calling "hud" that is the length of its parentView and 125.0 tall. I am using Auto Layout and here is a screenshot of my story board so you can see how I have the constraints set up. The container view is a collection view of photos.
I have the "hud" hide right away with a transform downward and when a photo is selected it will slide back up into view.
-(void)showHud:(BOOL)show
{
NSLog(@"Frame Height: %f", hud.frame.size.height);
if (show && !hudSelectionMode)
{
[UIView animateWithDuration:0.5 delay:0 options:0
animations:^{
hud.transform = CGAffineTransformMakeTranslation(0, 0);
hud.alpha = 0.8f;
}
completion:^(BOOL finished){
}
];
}
else if (!show && !hudSelectionMode)
{
[UIView animateWithDuration:0.5 delay:0 options:0
animations:^{
hud.transform = CGAffineTransformMakeTranslation(0, hud.frame.size.height);
hud.alpha = 0.8f; // will be 0.0 when not testing
}
completion:^(BOOL finished){
}
];
}
}
Here is the problem On iOS8 this works flawlessly the hud is hidden from the start and will slide up when an image is selected:
However when running on iOS7 devices the hud is not where I would expect it to be:
If I comment out all the code in -(void)showHud:(BOOL)show the hud will sit at the bottom of the parentView where I would expect it to on both 7 and 8.
On iOS7 you need to multiply the translation value by the scaleFactor of the device. On iOS8 this seems to be done automatically, but not on iOS7.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With