Reputation: 1303
On iOS 8 this code above works properly, but not on iOS 7, anybody knows how to fix it?
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
// headerFixed is an UIView inside of a headerView, i wanna it to be fixed on Y:0
headerFixed.transform = CGAffineTransformMakeTranslation(0, MIN(scrollView.contentOffset.y, 0));
}
on iOS 8: https://www.youtube.com/watch?v=-428J20xbzM&feature=youtu.be
on iOS 7 (BUG): https://www.youtube.com/watch?v=Dd_jh0zs1f0&feature=youtu.be
Upvotes: 2
Views: 1207
Reputation: 500
If you build your project with iOS 8 SDK, then on iOS 7 you'll have to manually convert points to pixels on retina devices;
Consider writing something like this:
CGFloat dY = MIN(scrollView.contentOffset.y, 0);
if ([UIDevice currentDevice].systemVersion.floatValue < 8) {
dY *= [UIScreen mainScreen].scale;
}
headerFixed.transform = CGAffineTransformMakeTranslation(0, dY);
There's a chance though that turning auto layout off will be enough to fix your problem.
Upvotes: 7