Reputation: 395
I have a NSSegmentedControl that I want to set the width and I want this control to fill all the space I have given to it. Also, I want the segments of the NSSegmentedControl to be evenly spaced among all segments (independently of available space or content). How can I achieve that?
Thanks in advance.
Upvotes: 0
Views: 1099
Reputation: 46543
You can do it by two ways:
Through Interface Builder.
Through Code, for dynamism.
[self.segmentControl setWidth:100 forSegment:0];
Do it for all others segment, loop can be used
EDIT:
- (IBAction)resizeSegmentedControl:(id)sender {
double segmentControlWidth=self.segmentControl.frame.size.width;
[self.segmentControl setWidth:segmentControlWidth/3-3 forSegment:0];
[self.segmentControl setWidth:segmentControlWidth/3-3 forSegment:1];
[self.segmentControl setWidth:segmentControlWidth/3-3 forSegment:2];
}
Upvotes: 1