本文实例为大家分享了ios记住密码整体button 的实现代码,供大家参考,具体内容如下
一、效果图
二、工程图
三、代码
rootviewcontroller.h
1
2
3
4
5
6
7
8
9
10
11
|
#import <uikit/uikit.h>
@ class becheckbox;
@interface rootviewcontroller : uiviewcontroller
{
becheckbox *passwordcheck;
}
@property(nonatomic,retain)becheckbox *passwordcheck;
@end
|
rootviewcontroller.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#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.
}
|
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。