C# Monotouch/Xamarin - Replace Entire Tab Button With Image In UITabBarController

梦想与她 提交于 2019-12-11 05:58:59

问题


Is it possible to replace the entire tab button for each tab with a different image in the UITabBarController?

INSTEAD OF THIS - (Standard Default Tab Controller Appearance)

DO THIS - (Custom Tab Controller Appearance Using Images)

How would I go about doing this?

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....


回答1:


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):



来源:https://stackoverflow.com/questions/19660401/c-sharp-monotouch-xamarin-replace-entire-tab-button-with-image-in-uitabbarcont

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!