【问题标题】:I want to set a background to the TabBar我想为 TabBar 设置背景
【发布时间】:2022-06-10 21:49:16
【问题描述】:

我不知道如何通过图像更改 TabBar 的背景(我尝试更改 TabBar 的背景,而不是尝试通过图像更改 TabBar 图标) 我尝试为我的 TabBar 设置背景,例如右侧程序的 TabBar

【问题讨论】:

    标签: swiftui tabbar tabview


    【解决方案1】:

    假设您的资产目录中有正确的图像(或提前准备好),您可以在视图的 init 中设置它,例如

    struct ContentView: View {
        init() {
            let appearance = UITabBarAppearance()
            appearance.configureWithOpaqueBackground()
            appearance.backgroundImage = UIImage(named: "image")
            UITabBar.appearance().scrollEdgeAppearance = appearance
        }
    
       // ... other code
    }
    

    backup

    【讨论】:

    • 但是我不知道正确图片的大小所以,你能帮我吗????
    猜你喜欢
    • 2015-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-20
    • 1970-01-01
    • 1970-01-01
    • 2012-03-05
    • 2011-10-03
    相关资源
    最近更新 更多