Instagram-like navigation bar (iOS 7)

后端 未结 4 550
无人及你
无人及你 2020-12-24 11:01

I\'m trying to make same affect, as instagram has in their header. How can I do this?

I tried a lot of solutions.

Best - https://github.com/andreamazz/AMScro

4条回答
  •  春和景丽
    2020-12-24 11:46

    You can use the below mentioned method in your class in which you want to add effect on navigation bar as there in Instagram.

    - (void)scrollViewDidScroll:(UIScrollView *)sender {
    //Initializing the views and the new frame sizes.
    UINavigationBar *navbar =self.navigationController.navigationBar;
    UIView *tableView = self.view;
    CGRect navBarFrame = self.navigationController.navigationBar.frame;
    
    CGRect tableFrame = self.view.frame;
    
    //changing the origin.y based on the current scroll view.
    //Adding +20 for the Status Bar since the offset is tied into that.
    
    if (isiOS7) {
         navBarFrame.origin.y = MIN(0, MAX(-44, (sender.contentOffset.y * -1)))  +20 ;
         tableFrame.origin.y = navBarFrame.origin.y + navBarFrame.size.height;
    }else{
        navBarFrame.origin.y = MIN(0, (sender.contentOffset.y * -1)) +20;
        tableFrame.origin.y = MIN(0,MAX(-44,(sender.contentOffset.y * -1))) ;
    }
    
    navbar.frame = navBarFrame;
    tableView.frame = tableFrame;
    

    }

提交回复
热议问题