Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

因为tabbar上的点击控件是继承于uibarItem的 #9

Closed
TYQbag opened this issue Jun 6, 2017 · 21 comments
Closed

因为tabbar上的点击控件是继承于uibarItem的 #9

TYQbag opened this issue Jun 6, 2017 · 21 comments

Comments

@TYQbag
Copy link

TYQbag commented Jun 6, 2017

No description provided.

@lixiang1994
Copy link
Owner

恩 , 这个你看我demo 参考一下 , 里面有对UITabBar这块的设置

@TYQbag
Copy link
Author

TYQbag commented Jun 7, 2017

我看了,这个tabbarItem上的图片你是写死的,我要用json来控制主题的切换,使用标签

@lixiang1994
Copy link
Owner

噢噢噢 那你直接给UITabBarItem的image属性添加设置就可以了 哈哈

@TYQbag
Copy link
Author

TYQbag commented Jun 8, 2017

重点是你没有为UITabBarItem设置对应的属性啊,我试了好几个都是直接崩溃,UITabBarItem这个有两种状态的,一个是选择时的图片,和没有选时的图片,求指点

@TYQbag
Copy link
Author

TYQbag commented Jun 8, 2017

我刚刚设置成功了,但是uitabbaritem的图片强加了渲染模式,就是这个属性UIImageRenderingMode,导致图片显示与原图差别很大,感觉这个属性一定要是 item.image = [[UIImage imageNamed:@“” imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];才有效,我这样: [item3.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];,就完全没用

@TYQbag
Copy link
Author

TYQbag commented Jun 12, 2017

大神,可以回复下嘛

@lixiang1994
Copy link
Owner

对的 我猜测item在setImage时才会触发一些设置 而 你在设置image后 再设置image的mode 并不会再调用setImage 所以item的样式没有发生变化.

@lixiang1994
Copy link
Owner

你现在解决这个问题了吗?

@TYQbag
Copy link
Author

TYQbag commented Jun 13, 2017

没有,不知道怎么玩了,你有解决的方案吗,一般主题很重要一部分就是tabbar的样式,但是我又不想自定义tabbar

@lixiang1994
Copy link
Owner

你的每个主题的图片是在工程里面吗? 还是存在沙盒?

@TYQbag
Copy link
Author

TYQbag commented Jun 13, 2017

打算存沙盒里面去

@lixiang1994
Copy link
Owner

tabBarItem.lee_theme.LeeCustomConfig(@"ident", ^(UITabBarItem *item, id value) {
            
            NSString *path = [LEETheme getResourcesPathWithTag:[LEETheme currentThemeTag]];
            
            UIImage *image = nil;
            
            if (path) {
                
                NSString *documentsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
                
                path = [documentsPath stringByAppendingPathComponent:path];
                
                image = [UIImage imageWithContentsOfFile:[path stringByAppendingPathComponent:value]];
                
            } else {
                
                image = [UIImage imageNamed:value];
            }
            
            if (image) item.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        });

@lixiang1994
Copy link
Owner

这样子 你试试看

@TYQbag
Copy link
Author

TYQbag commented Jun 13, 2017

好,谢谢啊,下午试试,到时再反馈你

@TYQbag
Copy link
Author

TYQbag commented Jun 15, 2017

不行啊,完全不走里面的方法

@lixiang1994
Copy link
Owner

不走? 你的标识符设置对吗

@lixiang1994
Copy link
Owner

你把你的这段代码发上来 我看一下

@lixiang1994
Copy link
Owner

你需要注意 这个标识符 在json的哪个类型中 (color , image , other)
如果你这个标识符在 image中 , 那么就不用去做获取 UIImage对象的操作了这个value应该就是 UIImage对象 你只需要设置一下他的mode就行了
如果你这个标识符在other中 , 那么value会是NSString类型的对象 参照我上面的代码处理就可以了

@TYQbag
Copy link
Author

TYQbag commented Jun 16, 2017

好,我再去试试

@TYQbag
Copy link
Author

TYQbag commented Jun 16, 2017

可以了,我之前是把tag认为是主题的tag了,谢谢啦

@yangfan1233
Copy link

最后怎么设置好的?能看下代码吗?我的设置tabbar图片怎么一直有问题,选中字体颜色也不能及时切换过来,方便的话能加下QQ吗,我的QQ:847993171

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants