Change height of the UISegmentedControl


UISegmentedControl changing height is sometimes difficult to find. It can be easily done if you are using constraints.

In case if you don't use constraints , I tried the following approach which I though would work, but actually it did not.

- (void)viewDidLoad {
    [super viewDidLoad];
    CGRect rect=self.seg_cntrl.frame;
    rect.size.height=60.0;
    [self.mySegmentControl setFrame:rect];
}

Later on I found if you try to create a UISegmentedControl object using a code and then set the Frame it will consider the height that you set.


- (void)viewDidLoad {
    [super viewDidLoad];
    
    UISegmentedControl *seg=[[UISegmentedControl alloc] initWithItems:@[@"1",@"2"]]
    ;
    [seg setFrame:CGRectMake(25.0, 70.0, 300.0, 60.0)];
    [self.view addSubview:seg];

}

The result can be seen in the following image.




Comments

Popular posts from this blog

hitTest on iOS to identify the view being hit

CMTimeMakeWithSeconds explained

Custom Editing Control for UITableViewCell , like iPhone Mail Appliation