IOS代码笔记之勾选"记住密码"整体button
程序员文章站
2023-12-15 10:40:10
本文实例为大家分享了ios记住密码整体button 的实现代码,供大家参考,具体内容如下
一、效果图
二、工程图
三、代码...
本文实例为大家分享了ios记住密码整体button 的实现代码,供大家参考,具体内容如下
一、效果图
二、工程图
三、代码
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. }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。