当使用类代理自定义UIButton外观时,UIBarItems似乎最初使用为UIButton设置的自定义属性。
从使用Core数据的默认主/详细项目开始。自定义UIButton在AppDelegate中的外观并运行应用程序。单击“编辑”按钮,然后单击MasterViewController导航栏中的“完成”按钮,然后观看自定义操作消失。
AppDelegate应用程序中的自定义外观代码:didFinishLaunchingWithOptions
UIImage *customBackground = [[UIImage imageNamed:@"yourcustomimage.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(5,5,5,5)];
[[UIButton appearance] setBackgroundImage:customBackground forState:UIControlStateNormal];

使用自定义背景初始化所有UIBarButtonItems

将“编辑”按钮替换为“已完成”按钮时,它将正确地没有自定义的背景。
A similar question asks how to customize the Done button。我担心为什么UIBarItem对象会发生这种情况,这些对象不是从UIButton继承的,我想知道如何纠正它。
我怀疑代理继承和支持的属性,但我不知道如何纠正它。有什么建议吗?
发布于 2013-04-13 17:59:04
我的建议是,当backgroundImage包含在UINavigationBar中时,将UINavigationBar重置为nil
[[UIButton appearance] setBackgroundImage:customBackground forState:UIControlStateNormal];
[[UIButton appearanceWhenContainedIn:[UINavigationBar class], nil] setBackgroundImage:nil forState:UIControlStateNormal];https://stackoverflow.com/questions/8734419
复制相似问题