iOS 7 parallax effect in my view controller

前端 未结 9 2074
终归单人心
终归单人心 2020-11-30 16:27

I\'m developing an app for iOS 7 in Objective-C. I\'ve got a screen in my app with a few buttons and a pretty background image. (It\'s a simple xib with UIButtons

9条回答
  •  执念已碎
    2020-11-30 16:32

    Really dam easy to do so why refers complex code. just try it. Working

    Take a view on imageview exactly size of image view. by default alpha for view set 0.

    //MARK: Scroll View Delegate methods
    -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
    NSLog(@"X: %f Y: %f",scrollView.contentOffset.x,scrollView.contentOffset.y);
    
    CGFloat scrollY = _mainScrollView.contentOffset.y;
    CGFloat height = _alphaView.frame.size.height;
    
    CGFloat alphaMonitor = scrollY/height;
    
    _alphaView.alpha = alphaMonitor;
    }
    

提交回复
热议问题