Questions tagged [uisegmentedcontrol]
UISegmentedControl is a class from UIKit in Apple iOS framework. A UISegmentedControl object is a horizontal control made of multiple segments, each segment functioning as a discrete button.
                                	
	uisegmentedcontrol
    
                            
                        
                    
            1,829
            questions
        
        
            343
            votes
        
        
            22
            answers
        
        
            239k
            views
        
    Color Tint UIButton Image
                I noticed that when I place a white or black UIImage into a UISegmentedControl it automatically color masks it to match the tint of the segmented control. I thought this was really cool, and was ...
            
        
       
    
            236
            votes
        
        
            17
            answers
        
        
            114k
            views
        
    Change font size of UISegmentedControl
                Can anyone please tell me how can I change the font type and size of UISegmentedControl?
            
        
       
    
            151
            votes
        
        
            18
            answers
        
        
            96k
            views
        
    How to change the colors of a segment in a UISegmentedControl in iOS 13?
                A UISegmentedControl has a new appearance in iOS 13 and existing code to alter the colors of the segmented control no longer work as they did.
Prior to iOS 13 you could set the tintColor and that ...
            
        
       
    
            101
            votes
        
        
            10
            answers
        
        
            32k
            views
        
    UISegmentedControl below UINavigationbar in iOS 7
                How do I make a UISegmentedControl as a part of an UINavigationBar below it? Is it connected to the UINavigationBar or is it a complete separate view just added as a subview to the ...
            
        
       
    
            91
            votes
        
        
            12
            answers
        
        
            90k
            views
        
    How to change font color of UISegmentedControl
                I try to change font color from white to black for UISegmentedControl (for iOS 4.*)
UISegmentedControl *button = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:itemTitle, nil]] ...
            
        
       
    
            89
            votes
        
        
            4
            answers
        
        
            59k
            views
        
    get string value from UISegmentedControl
                How can I get the text value of a segment in a UISegmentedControl?
            
        
       
    
            87
            votes
        
        
            8
            answers
        
        
            55k
            views
        
    UISegmentedControl change number of segments programmatically
                Is there a way to change the number of segments programmatically?
            
        
       
    
            83
            votes
        
        
            9
            answers
        
        
            98k
            views
        
    How do I use a UISegmentedControl to switch views?
                I'm trying to figure out how to use the different states of a UISegmentedControl to switch views, similar to how Apple does it in the App Store when switiching between 'Top Paid' and 'Top Free'.
            
        
       
    
            82
            votes
        
        
            7
            answers
        
        
            43k
            views
        
    How do I switch UISegmentedControl programmatically?
                How do I switch UISegmentedControl programmatically?
            
        
       
    
            73
            votes
        
        
            23
            answers
        
        
            99k
            views
        
    UISegmentedControl selected segment color
                Is there any way to customize color of selected segment in UISegmentedControl?
I've found segmentedController.tintColor property, which lets me customize color of the whole segmented control. 
The ...
            
        
       
    
            69
            votes
        
        
            8
            answers
        
        
            104k
            views
        
    How to programmatically add a UISegmentedControl to a container view
                How would I define the frame for a UISegmentedControl? 
I would like the segmented control to appear at the bottom of a container view i.e UIView.
            
        
       
    
            68
            votes
        
        
            16
            answers
        
        
            55k
            views
        
    iOS: change the height of UISegmentedcontrol
                I am trying to change the height of UISegmentedcontrol, but it is not allowed in the Interface Builder. Is there any way to change or it is impossible?
Thanks
            
        
       
    
            67
            votes
        
        
            8
            answers
        
        
            78k
            views
        
    Define click event for UISegmentedControl
                I have added a UISegmentedControl in my application.  None of the buttons are selected in normal state.  I want to implement a button click event when the first segment is selected, and another event ...
            
        
       
    
            66
            votes
        
        
            20
            answers
        
        
            39k
            views
        
    UISegmentedControl register taps on selected segment
                I have a segmented control where the user can select how to order a list. Works fine.
However, I would like that when an already selected segment is tapped, the order gets inverted. I have all the ...
            
        
       
    
            61
            votes
        
        
            2
            answers
        
        
            169k
            views
        
    How to fix Error: this class is not key value coding-compliant for the key tableView.' [duplicate]
                I made an app with Table View and Segmented Control, and this is my first time. I'm using some code and some tutorials, but It's not working. When I run my app It's crashing and it's showing this ...
            
        
       
    
            57
            votes
        
        
            2
            answers
        
        
            25k
            views
        
    How to disable part of UISegmentedControl?
                Following is the code for UISegmentedControl
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects: [UIImage imageNamed:@"down.png"], [UIImage ...
            
        
       
    
            54
            votes
        
        
            8
            answers
        
        
            33k
            views
        
    UISegmentedControl deselect (make none of the segments selected)
                in fact the title contains my question.
I have a UISegmentedControl, and need to deselect currently selected tab.
I tried: 
[menu setSelectedSegmentIndex:-1];
menu being the UBOutlet for ...
            
        
       
    
            53
            votes
        
        
            12
            answers
        
        
            53k
            views
        
    How to change the corner radius of UISegmentedControl?
                Is it possible to change the corner radius of UISegmentedControl? I have tried the following approach which we use to change a UIView's corner radius.
self.segmentedControl.layer.cornerRadius = 15.0;
...
            
        
       
    
            48
            votes
        
        
            7
            answers
        
        
            64k
            views
        
    Swift handle action on segmented control
                I have a HMSegmentedControl with 4 segments. When it is selected, it should pop up view. And when the pop up dismissed, and trying to click on same segment index it should again show the pop up. By ...
            
        
       
    
            46
            votes
        
        
            16
            answers
        
        
            47k
            views
        
    how to change font size and font name of uisegmentedcontrol programmatically on swift?
                How to change font size and font name of uisegmentedcontrol programmatically? I used swift.
Here is my code:
self.mysegmentedControl = UISegmentedControl(items: [
        NSLocalizedString("Aaaaaa", ...
            
        
       
    
            42
            votes
        
        
            2
            answers
        
        
            21k
            views
        
    iOS SegmentedControl equivalent in Android [closed]
                What is a good Android analog of iOS's UISegmentedControl?
            
        
       
    
            41
            votes
        
        
            2
            answers
        
        
            59k
            views
        
    How to set selected segment index in UISegmentedControl?
                I'm trying to avoid an app crash here... I have a button that will remove a segment from a UISegmentedControl. If that button is pressed and the user has the segment to be removed selected, the ...
            
        
       
    
            38
            votes
        
        
            6
            answers
        
        
            30k
            views
        
    Switching ViewControllers with UISegmentedControl in iOS5
                I am trying something very simple but somehow I can't get it to work. All I try to do is switching between 2 View Controllers using an UISegmentedControl as you can see it for example in the App Store ...
            
        
       
    
            38
            votes
        
        
            3
            answers
        
        
            9k
            views
        
    How to prevent backgroundColor of UISegmentedControl bleeding beyond segmented border
                I've noticed that when I set a color for UISegmentedControl.backgroundColor, the color bleeds beyond the edges of the control (though not beyond the view's bounds). Here's an example with the ...
            
        
       
    
            38
            votes
        
        
            10
            answers
        
        
            66k
            views
        
    Custom UISegmentedControl
                How do I make a custom UISegmentedControl?
I have 2 images, 1 that should be displayed when the segment is active and the other if the segment is inactive. Can i override the style or something so i ...
            
        
       
    
            37
            votes
        
        
            2
            answers
        
        
            19k
            views
        
    UISegmentedControl change event not firing in iOS5
                I have a UISegmentedControl whose "Value changed" event is wired up in Interface Builder to call my controller's -(IBAction)segmentChangeAction:(id)sender;
When the user taps on the control to change ...
            
        
       
    
            33
            votes
        
        
            7
            answers
        
        
            20k
            views
        
    UISegmentedControl text with multiple lines?
                How can I make the text in one of the buttons in my UISegmentedControl span multiple lines?
            
        
       
    
            32
            votes
        
        
            8
            answers
        
        
            41k
            views
        
    Add segmented control to navigation bar and keep title with buttons
                I want to add segmented control to the navigation bar but also keep the title and buttons, like in iOS 7 Appstore purchased section (example)
I have tried adding segmented control as title view and ...
            
        
       
    
            31
            votes
        
        
            8
            answers
        
        
            13k
            views
        
    How to deselect a segment in Segmented control button permanently till its clicked again
                I have a UISegmentedControl with 4 segments. When it is selected, it should maintain the selected state. When the same segment is clicked again, it should deselect itself.
How to achieve this?
            
        
       
    
            28
            votes
        
        
            8
            answers
        
        
            11k
            views
        
    How to set backgroundColor of UISegmentedControl to white in iOS 13
                iOS 13 introduced some changes to the UISegmentedControl including a really nice animation when switching the selected segment. However I'm noticing that it's not displaying the backgroundColor ...
            
        
       
    
            27
            votes
        
        
            4
            answers
        
        
            39k
            views
        
    Custom UISwitch with image [closed]
                I need to implement a custom switch in a project. Currently what I have found is that we cannot alter with UISwitch in way to implement as shown in below image. I've followed posts and googled through ...
            
        
       
    
            27
            votes
        
        
            6
            answers
        
        
            21k
            views
        
    Customizing UISegmentedControl in iOS 5
                Here is my problem. I am customizing a UISegmentedControl by setting the background and divider images in the following way:
[[UISegmentedControl appearance] setDividerImage:...
            
        
       
    
            26
            votes
        
        
            3
            answers
        
        
            22k
            views
        
    Customizing Left & Right UISegmentedControl Buttons
                I'm trying to customize the following segmented control, using a left image for the first button and a right image for the second button. How would I do this using UIAppearance?
I want to change the ...
            
        
       
    
            26
            votes
        
        
            12
            answers
        
        
            54k
            views
        
    Customizing the colors of a UISegmentedControl
                Does anybody know of a way to customize the appearance of the string based UISegmentedControl? I am trying to set the background color of the cell and the text color differently depending on the ...
            
        
       
    
            25
            votes
        
        
            4
            answers
        
        
            17k
            views
        
    UISegmentedControl setImage: Bug in iOS7
                I have a UISegmentedControl in my app. As of iOS7 GM, the images I use are not showing up when run on iOS7 devices. Anyone else having this problem?
Here's what it looks like in iOS6.1 and earlier
.
...
            
        
       
    
            25
            votes
        
        
            3
            answers
        
        
            40k
            views
        
    How to change color of UISegmentedControl border in iOS7?
                How do I change the border color of the segmented controller in iOS7 without changing the text color?
It would be ideal if I could keep the line between the segments as is (i.e. same color as the ...
            
        
       
    
            23
            votes
        
        
            5
            answers
        
        
            22k
            views
        
    UISegmentedControl with square corners
                I would like to modify UISegmentedControl with a subclass to remove the rounded corners. I can't seem to set the cornerRadius. Making the SegmentedControl wider than the screen (and therefor "chop" ...
            
        
       
    
            23
            votes
        
        
            7
            answers
        
        
            29k
            views
        
    Toolbar with "Previous" and "Next" for Keyboard inputAccessoryView
                I've been trying to implement this toolbar, where only the 'Next' button is enabled when the top textField is the firstResponder and only the 'Previous' button is enabled when the bottom textField is ...
            
        
       
    
            22
            votes
        
        
            9
            answers
        
        
            26k
            views
        
    Remove UISegmentedControl separators completely. (iphone)
                Is there a way to completely remove the line separating the two segments in a UISegmentedControl?
Setting the segmentedControlStyle is not helping.
            
        
       
    
            22
            votes
        
        
            9
            answers
        
        
            32k
            views
        
    How to remove border from segmented control
                How do I remove the outside border of a segmented control? 
I've set the divider image to what I wanted but now to follow the mock of my app I need to have a segmented control without the outer border....
            
        
       
    
            22
            votes
        
        
            6
            answers
        
        
            17k
            views
        
    Swift how to set default text color for UISegmentedControl?
                I want to set colors for the text and background of UISegmentedControl. So I've four colors to set, the default and selected color of the text and background. 
I can use tintColor and backgroundColor ...
            
        
       
    
            22
            votes
        
        
            13
            answers
        
        
            16k
            views
        
    How do I set the accessibility label for a particular segment of a UISegmentedControl?
                We use KIF for our functional testing, and it uses the accessibility label of elements to determine where to send events.  I'm currently trying to test the behaviour of a UISegmentedControl, but in ...
            
        
       
    
            22
            votes
        
        
            5
            answers
        
        
            17k
            views
        
    Can I show an UISegmentedControl object in vertical?
                Is there anyone who can teach me how to show an UISegmentedControl object in vertical direction, instead of in horizontal direction?
            
        
       
    
            22
            votes
        
        
            3
            answers
        
        
            19k
            views
        
    UISegmentedControl Best Practice
                I'm trying to work out the "best" way to use a UISegmentedControl for an iPhone application.  I've read a few posts here on stackoverflow and seen a few people's ideas, but I can't quite sort out the ...
            
        
       
    
            20
            votes
        
        
            7
            answers
        
        
            21k
            views
        
    UISegmentedControl - altering height in Interface Builder
                I'm creating a number of static custom UITableViewCells and have dragged a UISegmentedControl onto one of the custom cells. 
Whilst the segmented control allows me to alter its width I cannot alter ...
            
        
       
    
            19
            votes
        
        
            6
            answers
        
        
            31k
            views
        
    How to add the UISegmentedControl in UINavigationBar?
                I have tried to add the UISegmentedControl to the bottom of UINavigationBar with title. But i cannot add it and I cannot add UISegmentedControl in the tableView.headerView,because i need the search ...
            
        
       
    
            18
            votes
        
        
            5
            answers
        
        
            39k
            views
        
    How to set image to the UISegmentedControl in iPhone?
                I am new to iPhone development. I have created UISegmentedControl having 2 segments. I want to display images for each segment instead of title. Here is my code 
NSArray *itemArray = [NSArray ...
            
        
       
    
            18
            votes
        
        
            6
            answers
        
        
            21k
            views
        
    How to display only bottom border for selected item in UISegmentedControl?
                I'm extremely new to iOS development and ran into some trouble while building an app for a course.
I created a segmented control and its init function (shown below) is being called in the view ...
            
        
       
    
            18
            votes
        
        
            7
            answers
        
        
            43k
            views
        
    Change UISegmentedControl selected index or value programmatically
                I have a UISegmentedControl with two segments (index: 0 and 1) that I am trying to reset programmatically to 0. When I run the command below it does not reset the segment index to 0 as expected. ...
            
        
       
    
            18
            votes
        
        
            4
            answers
        
        
            7k
            views
        
    UISegmentedControl bounds
                I want to give the following aspect to an UISegmentedControl:
Note the gray background view, and the white background of the segmented control non selected item.
But, if I give a white background to ...