Uisegment Property
1.segmentedControlStyle
Sets the display style for the segment.
typedef ns_enum (Nsinteger, Uisegmentedcontrolstyle) {
Uisegmentedcontrolstyleplain,//large plain system default tablet style
Segmentedcontrol.segmentedcontrolstyle = Uisegmentedcontrolstyleplain;
uisegmentedcontrolstylebordered,//large bordered black edge style
Segmentedcontrol.segmentedcontrolstyle = uisegmentedcontrolstylebordered;
Uisegmentedcontrolstylebar,//small Button/nav bar style. Tintable Bar Style
Segmentedcontrol.segmentedcontrolstyle = Uisegmentedcontrolstylebar;
uisegmentedcontrolstylebezeled,//DEPRECATED. Don't use the This style. Do not use this type, use will be error OH.
};
2.tintColor Gradient Color
Default Tintcolor is nil. Only used if style is Uisegmentedcontrolstylebar
Default NULL to set the gradient color only with Uisegmentedcontrolstylebar.
Segmentedcontrol.segmentedcontrolstyle = Uisegmentedcontrolstylebar;
Segmentedcontrol.tintcolor = [Uicolor Redcolor];
3.momentary settings are restored after clicking
Default is No
Segmentedcontrol.momentary = No;
Segmentedcontrol.momentary = YES;
4. numberOfSegments (Read only)
Gets the total number of options segmentedcontrol.numberofsegments
5. Selectedsegmentindex
Use to set the selected item or return the selected item.
Segmentedcontrol.selectedsegmentindex = 2;//Sets the default selection index
Segmentedcontrol.selectedsegmentindex//Get selected
6.-(void) Settitle: (NSString *) title Forsegmentatindex: (Nsuinteger) segment;
[Segmentedcontrol settitle:@ "The" forsegmentatindex:1];//set the topic of the specified index
7.-(void) SetImage: (UIImage *) image forsegmentatindex: (Nsuinteger) segment;
[Segmentedcontrol setimage:[uiimage imagenamed:@ "Lan.png"] forsegmentatindex:3];//set the picture of the specified index
8.-(void) Insertsegmentwithtitle: (nsstring*) title Atindex: (Nsuinteger) segment animated: (BOOL) animated;
[Segmentedcontrol insertsegmentwithtitle:@ "Add" atindex:3 animated:no];//insert an option at the specified index and set the title
9.-(void) Insertsegmentwithimage: (UIImage *) image atindex: (Nsuinteger) segment animated: (BOOL) animated;
[Segmentedcontrol insertsegmentwithimage:[uiimage imagenamed:@ "Mei.png"] atindex:2 animated:no];//Insert an option in the specified index and set the picture
10. -(void) Removesegmentatindex: (Nsuinteger) segment animated: (BOOL) animated;
[Segmentedcontrol removesegmentatindex:0 animated:no];//option to remove the specified index
One.-(void) removeallsegments;
Remove all options
[Segmentedcontrol removeallsegments];
-(void) SetWidth: (cgfloat) Width Forsegmentatindex: (nsuinteger) segment; Set to 0.0 width to autosize. Default is 0.0
The width of the tab defaults to 0, which allows you to set the tab width.
[Segmentedcontrol setwidth:70.0 forsegmentatindex:2];//Sets the width of the specified index option
-(void) Setcontentoffset: (cgsize) offset Forsegmentatindex: (Nsuinteger) segment; Adjust offset of image or text inside the segment. Default is (0,0)
[Segmentedcontrol setcontentoffset:cgsizemake (10,0) forsegmentatindex:1];
Sets the offset of the inner text or picture with the default position of the tab, which is the default position in the center of the tab.
-(void) setenabled: (BOOL) enabled Forsegmentatindex: (Nsuinteger) segment;
[Segmentedcontrol setenabled:no forsegmentatindex:4];//Setting the specified index option is not selectable
15. Increase incident Response mechanism
The listener is this event: uicontroleventvaluechanged, Value Change event
[Segmentedcontrol addtarget:self Action: @selector (ItemClick) forcontrolevents:uicontroleventvaluechanged];
iOS Development UI Foundation Uisegment Properties