【问题标题】:Change Image when clicking tabbar单击标签栏时更改图像
【发布时间】:2020-08-17 01:55:23
【问题描述】:

我希望能够单击我的个人资料选项卡并将图像更改为更粗的个人资料图标。我有两张图片。用户在选项卡上选择时如何更改图片?

if selectedIndex == 3 {
            self.tabBarController?.tabBar.items?[3].image = UIImage(named: "AppIcon")
        }

这是在标签栏视图控制器中。我认为这只会运行一次。我想让它在他们每次点击它时运行

【问题讨论】:

标签: swift xcode tabbar


【解决方案1】:

您可以使用一个功能来检测UITabBarControllerDelegate中的选定选项卡

tabBarController(_ tabBarController: UITabBarController, 
                 didSelect viewController: UIViewController)

【讨论】:

    猜你喜欢
    • 2014-11-16
    • 1970-01-01
    • 2019-07-14
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 2016-04-23
    • 1970-01-01
    相关资源
    最近更新 更多