Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Can the font size of text items shown in the tabs of a UISegmentedControl be changed? I need to make the text slightly smaller as it is quite big by default.
Call the function with your UISegmentedControl as the parameter. You can change the two calls to customize the label to your liking (or add extra parameters to the function). I added the setTextAlignment call because when I made the font smaller the label text was then offset to the left. There may be a better way to address this but the above approach seems to work well enough.
I thought the selected/non-selected states of the bar style segmented control were too difficult to distinguish. I prefer the higher contrast difference used by the plain style. Now that I know how segmented controls are constructed I can customize them in all kinds of ways.
Sometimes, you can do it doesn't mean you should do it.
If I see a segmented control with a non-standard font, I would think the app is not very professional. I brokes the standard interface of iPhone UI.
I understand that you want to fit more text. However, you should think of some alternatives. For example, use a short word in the control, and have a label below it to give a long explanation.
Was searching for a solution to this problem. Well my solution is not elegant, but took less time than searching for a different answer and meets my needs. I used IB here's what I did
in IB create a segmented controller create the number of segments you need erase the titles in each segment Make segmented controller the size you need Grab a label and drag it on top of the segmented controller. type in the text field the name of the segment Change the font size to the size you would like. Change the font (by clicking on the "t notepad" and in the font section change to custom for a large selection of fonts) "command c" to copy / "command v" to copy and paste label with same settings to the next segment and so on.
Don't forget to hook up segmented controller to the file owner so each segment can still go where you want it to go.
FYI -to edit all labels at the same time: If you click on 1st label and then Command click on the rest of the labels, you can group change attributes (like font type n size and adjust alignment and such)
Replies
void changeUISegmentFont(UIView* aView) {NSString* typeName = [[aView class] className];
if ([typeName compare:@\"UISegmentLabel\" options:NSLiteralSearch] == NSOrderedSame) {
UILabel* label = (UILabel*)aView;
[label setTextAlignment:UITextAlignmentCenter];
[label setFont:[UIFont boldSystemFontOfSize:14]];
}
NSArray* subs = [aView subviews];
NSEnumerator* iter = [subs objectEnumerator];
UIView* subView;
while (subView = [iter nextObject]) {
changeUISegmentFont(subView);
}
}
Call the function with your UISegmentedControl as the parameter. You can change the two calls to customize the label to your liking (or add extra parameters to the function). I added the setTextAlignment call because when I made the font smaller the label text was then offset to the left. There may be a better way to address this but the above approach seems to work well enough.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeIf I see a segmented control with a non-standard font, I would think the app is not very professional. I brokes the standard interface of iPhone UI.
I understand that you want to fit more text. However, you should think of some alternatives. For example, use a short word in the control, and have a label below it to give a long explanation.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomehow to increase width of UIsegmented control Bar?
Thanxxxxxxxxx
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeyourSegmentedControl.frame = CGRectMake(x,y,w,h);
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomehow to change title name of UIsegmented control item?
Thanx.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomein IB create a segmented controller
create the number of segments you need
erase the titles in each segment
Make segmented controller the size you need
Grab a label and drag it on top of the segmented controller.
type in the text field the name of the segment
Change the font size to the size you would like.
Change the font (by clicking on the "t notepad" and in the font section change to custom for a large selection of fonts)
"command c" to copy / "command v" to copy and paste label with same settings to the next segment and so on.
Don't forget to hook up segmented controller to the file owner so each segment can still go where you want it to go.
FYI -to edit all labels at the same time: If you click on 1st label and then Command click on the rest of the labels, you can group change attributes (like font type n size and adjust alignment and such)
Hope it helps someone.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome