C# Monotouch/Xamarin - 在 UITabBarController 中用图像替换整个选项卡按钮 [英] C# Monotouch/Xamarin - Replace Entire Tab Button With Image In UITabBarController
问题描述
是否可以在 UITabBarController 中用不同的图像替换每个选项卡的整个选项卡按钮?
Is it possible to replace the entire tab button for each tab with a different image in the UITabBarController?
取而代之的是 -(标准默认选项卡控制器外观)
这样做 -(使用图像的自定义标签控制器外观)
我该怎么做?
UITabBarController 的自定义看起来很讨厌.您可以更改色调颜色,但这会影响选项卡图像在各种选择/未选择状态下的颜色....
Customization of the UITabBarController seems pretty nasty. You can change the tint colour, but that affects the colour of the tab image in it's various selected/not-selected states....
推荐答案
这并不明显.但这里介绍了如何使用全彩色图像并可选择省略文本标签.
It's not obvious. But here's how to use full colored images and optionally omit the text label.
var tabBarItem = new UITabBarItem("Item Text", null, 1);
tabBarItem.SetFinishedImages(UIImage.FromBundle("./Images/addexpense.png"), UIImage.FromBundle("./Images/addexpense.png"));
var controllerToAdd = new UIViewController()
{
TabBarItem = tabBarItem
};
tabBarController.SetViewControllers(new UIViewController[]
{
controllerToAdd
};
结果可能看起来像这样(当然,您也可以通过省略我的示例中显示的项目文本"来完全删除文本):
The result can then look something like this (of course you can also get rid of the text completely by omitting the "Item Text" shown in my example):
这篇关于C# Monotouch/Xamarin - 在 UITabBarController 中用图像替换整个选项卡按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!