IOS development check box class library sscheckboxview

Source: Internet
Author: User

Uiswitch is generally used for setting apps in iOS development, and occasionally appears monotonous. At this time, you can choose to use a third-party open-source class library sscheckboxview. Sscheckboxview is a check box UI control available on iOS. It provides two options: select and not selected, and 5.

GitHub: https://github.com/ardalahmet/SSCheckBoxView



The encapsulated sscheckboxview is easy to use. First, initialize its frame, set the display style and status, and add it to the view to display a check box.

- (void)viewDidLoad{    [super viewDidLoad];     SSCheckBoxView *cb = [[SSCheckBoxView alloc] initWithFrame:CGRectMake(50, 50, 30, 30) style:kSSCheckBoxViewStyleMono checked:YES];    [self.view addSubview:cb];    [cb release]; }


:


Five display styles. When passing parameters, you can set the display styles by passing the numbers between 0 and 5.

typedef enum SSCheckBoxViewStyle_ {    kSSCheckBoxViewStyleBox = 0,    kSSCheckBoxViewStyleDark,    kSSCheckBoxViewStyleGlossy,    kSSCheckBoxViewStyleGreen,    kSSCheckBoxViewStyleMono,    kSSCheckBoxViewStylesCount} SSCheckBoxViewStyle;

If you need to describe how to use the check box, set text, but you need to adapt the width of the sscheckboxview object. If the width is too short, the display is incomplete. You can observe the check box in two ways, one is the selector and the other is the block;

-(Void) viewdidload {[Super viewdidload]; sscheckboxview * cb = [[sscheckboxview alloc] initwithframe: cgrectmake (50, 50,300, 30) style: ksscheckboxviewstylemono checked: Yes]; [CB settext: @ "What is this?"]; [CB setstatechangedtarget: Self selector: @ selector (checkboxviewchangedstate :)]; [self. view addsubview: CB]; [CB release]; sscheckboxview * CB2 = [[sscheckboxview alloc] initwithframe: cgrectmake (50, 80,300, 30) style: 3 checked: Yes]; [CB2 settext: @ "Use block to check whether selected"]; [CB2 setstatechangedblock: ^ (sscheckboxview * CBV) {nslog (@ "check box status: % @", CBV. checked? @ "Selected": @ "not selected") ;}]; [self. view addsubview: CB2]; [CB2 release];}-(void) checkboxviewchangedstate :( sscheckboxview *) CBV {nslog (@ "check box status: % @", CBV. checked? @ "Selected": @ "not selected ");}

:



Original blog welcome to repost share, please indicate the source of http://blog.csdn.net/duxinfeng2010

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.