Hello,
If you want to custom the TabBar
's bar title, you need to override the CreateTabBarAppearanceTracker
method. Then set the title to the center like the following code.
[assembly: ExportRenderer(typeof(Shell), typeof(MyCustomrender))]
namespace App1.iOS
{
internal class MyCustomrender: ShellRenderer
{
protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker()
{
return new MyCreateTabBarAppearanceTracker();
}
}
internal class MyCreateTabBarAppearanceTracker : IShellTabBarAppearanceTracker
{
public void Dispose()
{
}
public void ResetAppearance(UITabBarController controller)
{
}
public void SetAppearance(UITabBarController controller, ShellAppearance appearance)
{
var items = controller.TabBar.Items;
for (int i = 0; i < items.Length; i++)
{
if (items[i] == null) continue;
else
{
UITabBarItem item_temp = items[i];
UIView view = item_temp.ValueForKey(new Foundation.NSString("view")) as UIView;
UILabel label = view.Subviews[1] as UILabel;
label.Lines = 2;
label.LineBreakMode = UILineBreakMode.WordWrap;
label.TextAlignment = UITextAlignment.Center;
}
}
}
public void UpdateLayout(UITabBarController controller)
{
}
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.