Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7008899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:47:40+00:00 2026-05-27T21:47:40+00:00

In my segmented control, sometimes the title is wider than fits its segment. How

  • 0

In my segmented control, sometimes the title is wider than fits its segment. How can I make it truncate?

Let’s say the title of segment 1 is Text overlaps and segment 2 is named ok.

How I want it to look:

  [Text ov...|   ok   ]

What it looks like:

 T[ext overla|ps  ok   ]

What I tried:

  • Setting the width of the segment programmatically setWidth:forSegment. Still overlapping, not truncating.
  • Studying the properties of UISegmentedControl

Do I have to truncate it myself, before setting the title of the segment?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:47:41+00:00Added an answer on May 27, 2026 at 9:47 pm

    You have to truncate it yourself.

    There is no public API for setting the truncation. Even if you dig through the UISegmentedControl‘s private view hierarchy, find the labels, and set lineBreakMode to UILineBreakModeTailTruncation, it won’t truncate the labels for you. (I tried.)

    EDIT: I got this to work. It’s not pretty, it might stop working in a future iOS release, and it might get you rejected from the App Store.

    static void fixLineBreakMode(UIView *view)
    {
        if ([view respondsToSelector:@selector(setLineBreakMode:)]) {
            [(id)view setLineBreakMode:UILineBreakModeTailTruncation];
            [view setFrame:CGRectInset([view.superview bounds], 6, 0)];
        } else {
            for (UIView *subview in view.subviews)
                fixLineBreakMode(subview);
        }
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        fixLineBreakMode(self.segmentedControl);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to make one segment of a segmented control invisible?
I can't seem to make my segmented control, which is within a tableview smaller?
I have a segmented control where the user can select how to order a
I have a UINavigationController. In its toolbar is a segmented control with two buttons.
How can I get whats been selected in a segmented control?
can anybody help with the code on how to add segmented control within the
Hi can any one can help me how to keep segmented control in the
I have four subview and when I select (segment ==1) in segmented control other
How can I give different background colors to segments in a segmented control
I create a custom right view as follows: // Build the Segmented Control NSArray

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.