本文實例為年夜家分享了IOS記住暗碼全體button 的完成代碼,供年夜家參考,詳細內容以下
1、後果圖
2、工程圖
3、代碼
RootViewController.h
#import <UIKit/UIKit.h> @class BECheckBox; @interface RootViewController : UIViewController { BECheckBox *passwordCheck; } @property(nonatomic,retain)BECheckBox *passwordCheck; @end
RootViewController.m
#import "RootViewController.h" //參加頭文件 #import "BECheckBox.h" @interface RootViewController () @end @implementation RootViewController @synthesize passwordCheck; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. //隱蔽導航條 self.navigationController.navigationBarHidden=YES; //忘卻暗碼按鈕 BECheckBox *passCheckBox=[[BECheckBox alloc]initWithFrame:CGRectMake(61, 55, 80, 30)]; [passCheckBox setTitle:@"記住暗碼" forState:UIControlStateNormal]; [passCheckBox setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; passCheckBox.titleLabel.font=[UIFont systemFontOfSize:16]; [passCheckBox setTarget:self fun:@selector(passCheckBoxClick)]; passCheckBox.backgroundColor=[UIColor clearColor]; self.passwordCheck=passCheckBox; [self.view addSubview:self.passwordCheck]; } //記住暗碼點擊 -(void)passCheckBoxClick { if ([self.passwordCheck isChecked]) { NSLog(@"記住暗碼"); } else { NSLog(@"撤消記住暗碼"); } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
以上就是本文的全體內容,願望對年夜家的進修有所贊助,也願望年夜家多多支撐本站。
【IOS代碼筆記之勾選"記住暗碼"全體button】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!