gpt4 book ai didi

ios4 - 自定义彩色 UITabBar 图标

转载 作者:行者123 更新时间:2023-12-02 02:29:31 25 4
gpt4 key购买 nike

我试图在 UITabBar 中实现自定义颜色。但我不知道问题是什么。我在 1 个 tabBar 上放置了一个图像。当 tabBar 处于事件状态时,我想要一个图像,当 tabBar 处于非事件状态时,我想要另一个图像在同一个tabBar上显示。如何?还指导我将图像放置在 tabBar 的中心。请告诉我此实现的 Xcode-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
for(UIView *view in self.tabBarController.tabBar.subviews) {
if([view isKindOfClass:[UIImageView class]]) {
[查看 removeFromSuperview];

}

[self.tabBarController.tabBar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Icon-a.png"]] autorelease] atIndex:0];  

}

  • (void)viewWillDisappear:(BOOL)动画{//[superviewWillDisappear:动画];for(UIView *view in self.tabBarController.tabBar.subviews) {
    if([view isKindOfClass:[UIImageView class]]) {
    [查看 removeFromSuperview];

    }

    [self.tabBarController.tabBar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Icon-c.png"]] autorelease] atIndex:0];

    我使用这些方法来实现我的任务。但是我没有得到解决方案。请帮助我

最佳答案

您可以引用以下链接中提供的源代码,希望它能解决您的问题.. https://github.com/rumex/RXCustomTabBar

关于ios4 - 自定义彩色 UITabBar 图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4314301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com