Twitter iOS Profile Page Configuration

后端 未结 2 2085
庸人自扰
庸人自扰 2021-02-19 11:16

I\'m trying to structure a page similar to Twitter\'s profile page. It looks like they are using a basic UITableView. The top profile is just the tableHeaderView. T

相关标签:
2条回答
  • 2021-02-19 11:54

    I'm 99% certain they are simply adjusting the scroll indicator insets as you scroll view the table:

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
    {
        CGFloat const visibleHeaderHeight = 0.0; // your logic here
        UIEdgeInsets const insets = UIEdgeInsetsMake(visibleHeaderHeight, 0.0, 0.0, 0.0);
    
        self.scrollView. scrollIndicatorInsets = insets;
    }
    

    Also I'm pretty sure they are using a grouped style table view due to the sectioning, so you would need to build the sticky header yourself. You can also do that in -scrollViewDidScroll: though.


    If you want to break the tabs into separate view controllers, I would recommend the following setup:

    • have a container view controller managing the header view containing the tabs
    • use UIViewController containment to plug in the active view controller
    • subscribe to the active view controller's scroll view's contentOffset and adjust the scroll indicator inset and sticky header y position accordingly
    0 讨论(0)
  • 2021-02-19 12:09

    I tried to explain a bit here.

    After a long long investigation that is how i achieve the twitter profile behaviour.

    • UnderlayScrollView
    • MasterScrollView
      • Header ViewController
      • Bottom ViewController
        • PagerTabItems [CollectionView]
        • UIPagerController or any other horizontal scroll (Parchment, XLPagerTabStrip).

    UnderlayScrollView is responsible of controlling the scroll gesture. its contentoffset is used to adjust inner scroll contentOffsets. Contentsize of the underlaying scroll is same as the masterscroll's contentsize.

    See the source code on github for more. click

    0 讨论(0)
提交回复
热议问题