You can choose to use a third-party open-source class library Sscheckboxview when you set up your application in iOS development in general with Uiswitch, which occasionally appears monotonous.
Sscheckboxview is a check box available on iOS UI control that provides check and uncheck two cases, and 5 styles, such as
Github:https://github.com/ardalahmet/sscheckboxview
The encapsulated Sscheckboxview is also very simple to use, first initialize its frame, set the display style and whether it is selected, and then add to the view to complete the display of a check box
-(void) viewdidload{ [Super Viewdidload]; *CB = [[Sscheckboxview alloc] Initwithframe:cgrectmake (checked : YES]; [Self.view ADDSUBVIEW:CB];}
Five kinds of display style, the time to pass the parameter can also pass 0-5 between the number setting display style
typedef enum SSCHECKBOXVIEWSTYLE_ { ksscheckboxviewstylebox = 0, Ksscheckboxviewstyledark, Ksscheckboxviewstyleglossy, Ksscheckboxviewstylegreen, Ksscheckboxviewstylemono, Ksscheckboxviewstylescount} Sscheckboxviewstyle;
If you need to explain what the check box is for, set the text to fit, but the width of the Sscheckboxview object needs to be adapted, the width is too short to be displayed completely, the check box can be observed in two ways, one is to use the selected device, the other is to use block;
- (void) viewdidload{[Super Viewdidload]; Sscheckboxview*CB = [[Sscheckboxview alloc] Initwithframe:cgrectmake ( -, -, -, -) Style:ksscheckboxviewstylemonochecked: YES]; [CB SetText:@"What is this?"]; [CB setstatechangedtarget:self selector: @selector (checkboxviewchangedstate:)]; [Self.view ADDSUBVIEW:CB]; Sscheckboxview*CB2 = [[Sscheckboxview alloc] Initwithframe:cgrectmake ( -, the, -, -) Style:3 checked: YES]; [CB2 setText:@"use block to see if a check is selected"]; [CB2 setstatechangedblock:^ (Sscheckboxview *CBV) {NSLog (@"check box status:%@", CBV.checked?@"selected":@"not selected"); }]; [Self.view ADDSUBVIEW:CB2]; }-(void) Checkboxviewchangedstate: (sscheckboxview*) cbv{NSLog (@"check box status:%@", CBV.checked?@"selected":@"not selected");}
:
IOS: check box Use---Third-party framework Sscheckboxview-master