• 请不要在回答技术问题时复制粘贴 AI 生成的内容
CommandZi
V2EX  ›  程序员

求教 App Store 的 Segmented Control 的实现方式

  •  
  •   CommandZi · Sep 14, 2015 · 2522 views
    This topic created in 3923 days ago, the information mentioned may be changed or developed.

    看图:
    图一
    图二

    图一:排行榜这个 Segmented Control 是一个独立于 NavigationBar 的一个 View 吗?但我看到他好像是跟这个 Bar 融合在一起的。
    图二:详情的 Segmented Control 在自动布局的 ScrollView 里面,如何实现滞粘在 NavigationBar 下面?

    Supplement 1  ·  Sep 29, 2015

    我查看 App Store 的排行榜的 NavigationBar 以及已购项目的 NavigationBar ,两个的实现是不同的。请教大家排行榜这个是如何实现的。

    排行榜
    已购项目

    14 replies    2015-09-15 10:09:03 +08:00
    SeanChense
        1
    SeanChense  
       Sep 14, 2015
    第一个是 custom 了 NavigationBar ,其实就是紧挨着 NavigationBar
    第二个是 UITableView 的 section header view 吧
    LINAICAI
        2
    LINAICAI  
       Sep 14, 2015
    系统 NavigationBar 高度是可以那么高的。。。
    第二个如一楼说的 section header view
    pheyer
        3
    pheyer  
       Sep 14, 2015
    用 Reveal 这个软件看看就知道了
    Elethom
        4
    Elethom  
       Sep 14, 2015
    kobe1941
        5
    kobe1941  
       Sep 14, 2015
    第一个,你注意下高度,其实只要弄个 UIView 紧紧贴住 NavigationBar 即可,把 NavigationBar 下方的横线隐藏,看起来就是一体啦
    第二个就是 tableView 的一个 sectionHeader
    CommandZi
        6
    CommandZi  
    OP
       Sep 14, 2015
    @Elethom 搜到一些相关的,实现基本是像 5 楼说的加一个 UIView 到 Bar 下面,横线隐藏。
    @pheyer 无奈没有越狱的 iOS 设备。
    @LINAICAI 调整 Bar 的高度,但是上面的 BarButtonItem 也一起往下移,而无法修改 Item 的 frame 。
    @kobe1941 感谢
    @SeanChense 感谢
    Elethom
        7
    Elethom  
       Sep 14, 2015
    rvw
        8
    rvw  
       Sep 14, 2015
    第一种可以加在 navbar 上也可以在下面加一个 view 紧挨着 navbar ,第二种就是在页眉上了,滑动的时候判断一下让他停靠在 navbar 下面
    CommandZi
        9
    CommandZi  
    OP
       Sep 14, 2015
    @Elethom 哇,你真聪明。另外我还找到
    ![http://stackoverflow.com/questions/18813563/add-segmented-control-to-navigation-bar-and-keep-title-with-buttons]
    ![https://developer.apple.com/library/ios/samplecode/NavBar/Introduction/Intro.html]
    但还是比不上你聪明上天了。
    要你来教授我这样一个蠢人,我当之有愧啊。
    CommandZi
        10
    CommandZi  
    OP
       Sep 14, 2015
    此帖终结。
    第一个添加一个 toolBar 在 TableView 上面,设置好 tableView 的 contentInset 就 OK 了,使用 toolBar 而不是 UIView ,是因为 toolBar 的毛玻璃效果跟 navigationBar 是一样的。
    第二个选择 sectionHeader 。
    SeanChense
        11
    SeanChense  
       Sep 14, 2015 via iPhone
    @CommandZi 一般在技术区敢这么冲的,技术都很横。
    CommandZi
        12
    CommandZi  
    OP
       Sep 14, 2015
    @SeanChense 所以,他骂的对?我只知道“闻道有先后”。但是也许他那里说别人“蠢”是口头禅。
    LINAICAI
        13
    LINAICAI  
       Sep 14, 2015
    @CommandZi
    BarButtonItem 可以调整内容的偏移量
    kobe1941
        14
    kobe1941  
       Sep 15, 2015
    @CommandZi 第一个也可以直接设置好 tableView 的 frame ,我一般都这么干。。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   955 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 21:20 · PVG 05:20 · LAX 14:20 · JFK 17:20
    ♥ Do have faith in what you're doing.