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

[iOS] Shell tab titles don't truncate and they overlap in iOS unlike Android #20015

Closed
kklose23 opened this issue Jan 19, 2024 · 2 comments
Closed
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout platform/iOS 🍎 t/bug Something isn't working

Comments

@kklose23
Copy link

Description

When a shell tab has a long title, it will truncate in Android but overlap with other titles in iOS

iOS:
image

Android:
image

Steps to Reproduce

Create shell tabs with long titles

Link to public reproduction project repository

No response

Version with bug

8.0.6

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 17

Did you find any workaround?

No

I tried each of the following, which did not work:

public class CustomShellTabBarAppearanceTracker : ShellTabBarAppearanceTracker, IShellTabBarAppearanceTracker
{
  void IShellTabBarAppearanceTracker.SetAppearance(UITabBarController controller, ShellAppearance appearance)
  {
    base.SetAppearance(controller, appearance);

    var tabAppearance = controller.TabBar.StandardAppearance;

    var titleTextAttributes = controller
      .TabBar
      .StandardAppearance
      .StackedLayoutAppearance
      .Normal
      .TitleTextAttributes;

    titleTextAttributes.ForegroundColor = UIColor.Cyan;
    titleTextAttributes.ParagraphStyle = new NSMutableParagraphStyle
    {
      LineBreakMode = UILineBreakMode.TailTruncation
    };

    tabAppearance.StackedLayoutAppearance.Normal.TitleTextAttributes = titleTextAttributes;
    tabAppearance.InlineLayoutAppearance.Normal.TitleTextAttributes = titleTextAttributes;
    tabAppearance.CompactInlineLayoutAppearance.Normal.TitleTextAttributes = titleTextAttributes;
    tabAppearance.StackedLayoutAppearance.Selected.TitleTextAttributes = titleTextAttributes;
    tabAppearance.InlineLayoutAppearance.Selected.TitleTextAttributes = titleTextAttributes;
    tabAppearance.CompactInlineLayoutAppearance.Selected.TitleTextAttributes = titleTextAttributes;

    controller.TabBar.StandardAppearance = tabAppearance;
    controller.TabBar.ScrollEdgeAppearance = tabAppearance;
  }
}
  protected override IShellItemRenderer CreateShellItemRenderer(ShellItem item)
  {
    var renderer = base.CreateShellItemRenderer(item);
    if (renderer is not null)
    {
      if (renderer is ShellItemRenderer shellItem)
      {
        foreach (var tabBarItem in shellItem.TabBar.Items)
        {
          var uiView = tabBarItem.ValueForKey(new Foundation.NSString("view")) as UIView;
          if (uiView.Subviews.IsNotNullOrEmpty() && uiView.Subviews[1] is UILabel uiLabel)
          {
            uiLabel.LineBreakMode = UILineBreakMode.TailTruncation;
          }
        }
      }
    }

    return renderer;
  }

Relevant log output

No response

@kklose23 kklose23 added the t/bug Something isn't working label Jan 19, 2024
@Eilon Eilon added the area-controls-shell Shell Navigation, Routes, Tabs, Flyout label Jan 20, 2024
@kubaflo
Copy link
Collaborator

kubaflo commented Jan 23, 2024

This is a default iOS behavior. Not much to be done here
@jfversluis I suggest closing this issue
298961534-0bfb0d13-91c3-4d57-b180-79a452356b76-2

@jfversluis
Copy link
Member

Agreed, I think this is default iOS behavior, if you don't want to do this, truncate yourself and/or keep your tab titles short.

@jfversluis jfversluis closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout platform/iOS 🍎 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants