1

I want to make a button that has the same appearance as one of the segments of a bar style segment like this color:

enter image description here

But I dont know how to acheive the same gradient as it. My goal is to make a segment control with buttons that looks the same but you can select multiple "segments"

Community
  • 1
  • 1
BluGeni
  • 3,378
  • 8
  • 36
  • 64
  • 5
    Why not take the image you've uploaded here, crop a section of the gradient, and use that as a resizable image? – Cameron Jul 26 '13 at 02:21

3 Answers3

2

1. For enabling multiple selection,configure the Selection attribute of the segmented control as Multiple or do a search for custom multiple selection segments.

Selection.

Specifies the tracking mode of the segmented control. The possible options are:

Multiple: This corresponds to the constant NSSegmentSwitchTrackingSelectAny and specifies that any segment can be selected.

2.For the appearance,use the background gradient image

[mySegmentedControl insertSegmentWithImage:[UIImage imageNamed:@"gradient.png"] atIndex:0 animated:YES];

For more,please refer my answer here

Community
  • 1
  • 1
Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102
1

You can use this piece of code if you have images for selected and normal state images in gradient.

UIImage *segmentNormal = [[UIImage imageNamed:@"segmentNormal.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
[[UISegmentedControl appearance] setBackgroundImage:segmentNormal forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

UIImage *segmentSelected = [[UIImage imageNamed:@"segmentSelected.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)];
[[UISegmentedControl appearance] setBackgroundImage:segmentSelected forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
I_User
  • 325
  • 3
  • 18
0

All you want is here link

and for segments appearance you can set [UISegmentedControl appearance] property.

Toseef Khilji
  • 17,192
  • 12
  • 80
  • 121