ios – 在UITabBar上查看

ios – 在UITabBar上查看,第1张

概述与播放歌曲时Spotify或Apple Music应用程序的功能类似,它会在UITabBar上放置一个自定义视图: 我试过的解决方案: >具有最大容器视图的ViewController中的UITabBarController,以及底部布局指南上方Container View49pt顶部的自定义视图: 问题:嵌入在底部的UITabBarController中的ViewControllers中的任何内 与播放歌曲时Spotify或Apple Music应用程序的功能类似,它会在UITabbar上放置一个自定义视图:

我试过的解决方案:

>具有最大容器视图的VIEwController中的UITabbarController,以及底部布局指南上方Container VIEw49pt顶部的自定义视图:

问题:嵌入在底部的UITabbarController中的VIEwControllers中的任何内容都不会显示,因为它们隐藏在自定义布局后面.我已经尝试在UITabbarController中覆盖大小forChildContentContainer,尝试更新底部布局指南,nothing.我需要调整UITabbarController的容器视图的框架.
>再次尝试#1,但尝试在increasing the size of UITabBar之前解决隐藏在其后面的内容问题,然后使用ImageInset on every TabBarItem将其关闭,并在UITabbar上添加我的自定义视图.工作得不好.有时候我想隐藏自定义视图.
> UITabbarController作为root用户,每个子节点都是VIEwController,带有Container VIEw我的自定义视图:

但现在我有多个自定义视图实例浮动.如果我想更改其上的标签,则必须将其更改为所有视图.或隐藏等
>覆盖UITabbarController的UITabbar属性并返回我的自定义UITabbar(用xib充气),它具有UITabbar我的自定义视图.问题:可能是所有人最令人沮丧的尝试.如果使用类MyCustomTabbar:UITabbar {}的实例覆盖该属性,则不会显示任何选项卡!是的,我将myCustomTabbar的委托设置为self.

倾向于#3,但寻找更好的解决方案.

解决方法 我知道了!

本质上,我增加了原始UITabbar的大小以容纳自定义视图(并缩小上面的vIEwcontrollers的框架),然后在其上添加一个重复的UITabbar自定义视图.

这是我必须要做的事情.我上传了一个功能实例,可以是found in this repo:

class TabbarVIEwController: UITabbarController {    var currentlyPlaying: CurrentlyPlayingVIEw!    static let maxHeight = 100    static let minHeight = 49    static var tabbarHeight = maxHeight    overrIDe func vIEwDIDLoad() {        super.vIEwDIDLoad()        currentlyPlaying = CurrentlyPlayingVIEw(copyFrom: tabbar)        currentlyPlaying.tabbar.delegate = self        vIEw.addSubvIEw(currentlyPlaying)        tabbar.isHIDden = true    }    overrIDe func vIEwWillAppear(_ animated: Bool) {        super.vIEwWillAppear(animated)        currentlyPlaying.tabbar.items = tabbar.items        currentlyPlaying.tabbar.selectedItem = tabbar.selectedItem    }    func hIDeCurrentlyPlaying() {        TabbarVIEwController.tabbarHeight = TabbarVIEwController.minHeight        UIVIEw.animate(withDuration: 0.5,animations: {            self.currentlyPlaying.hIDeCustomVIEw()            self.updateSelectedVIEwControllerLayout()        })    }    func updateSelectedVIEwControllerLayout() {        tabbar.sizetoFit()        tabbar.sizetoFit()        currentlyPlaying.sizetoFit()        vIEw.setNeedsLayout()        vIEw.layoutIfNeeded()        vIEwControllers?[self.selectedindex].vIEw.setNeedsLayout()        vIEwControllers?[self.selectedindex].vIEw.layoutIfNeeded()    }}extension UITabbar {    open overrIDe func sizeThatFits(_ size: CGSize) -> CGSize {        var sizeThatFits = super.sizeThatFits(size)        sizeThatFits.height = CGfloat(TabbarVIEwController.tabbarHeight)        return sizeThatFits    }}
总结

以上是内存溢出为你收集整理的ios – 在UITabBar上查看全部内容,希望文章能够帮你解决ios – 在UITabBar上查看所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1108038.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存