Home > Tutorials Home > Ios > Segmented Control in iOS

Segmented Control in iOS

Published on October 17, 2019 8:14:22 PM


We are an online tutoring company that has laid its foundation in utilizing Multiple Intelligence methodology to understand specific needs and learning styles of a student.UISegmented Control shows a horizontal list of items. Each segment looks like a button. The segments remains pressed even after the user lifts his finger.When a different segment is tapped, its corresponding value can be obtained. So that we patch a particular student to a tutor having a compatible teaching style. We have devised a smart online tutoring system to give you measurable results.Schools, cramped with students, fail to give your child the edge, the motivation and the right teacher guidance to help him find the true potential. We at make sure that your child gets the perfect learning environment to outperform.

Step 1 : Open the XCode and create a new Single View Based Application template. Give the application name "SegmentedControl Example". Copy this Code to the ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@property (weak, nonatomic) IBOutlet UISegmentedControl *segControl;
@property (weak, nonatomic) IBOutlet UITextView *lbltextView;

- (IBAction)changeColor:(id)sender;


Step 2 : Copy the Following Code into your ViewController.m File.

#import "ViewController.h"

@implementation ViewController

@synthesize segControl;
@synthesize lbltextView;

- (IBAction)changeColor:(id)sender
   switch (segControl.selectedSegmentIndex) 
        case 0:
            lbltextView.textColor = [UIColor redColor];
        case 1:
            lbltextView.textColor = [UIColor greenColor];
		case 2:
			lbltextView.textColor = [UIColor blueColor];
		case 3:	
			lbltextView.textColor = [UIColor yellowColor];
			lbltextView.textColor = [UIColor blackColor];


Segmented Control in iOS - Video Tutorial