- (void)viewDidLoad {
//添加图片
UIImage *firstimage=[UIImage imageNamed:@"700.png"];
UIImageView *firstiamgeview=[[UIImageView alloc]initWithImage:firstimage];
[firstiamgeview setFrame:CGRectMake(120, 125, 60, 60)];
[self.view addSubview:firstiamgeview];
self.view.backgroundColor=[UIColor grayColor];
//登陆界面的点击登陆按钮
UIButton *logintouch=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[logintouch setTitle:@"点击登陆" forState:UIControlStateNormal];
[logintouch setFrame:CGRectMake(100, 400, 100, 30)];
[logintouch addTarget:self action:@selector(logintouchclicked:) forControlEvents:UIControlEventTouchUpInside];
logintouch.backgroundColor=[UIColor blueColor];
[self.view addSubview:logintouch];
//登陆界面的忘记密码按钮
UIButton *forgetpassword=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[forgetpassword setTitle:@"忘记密码" forState:UIControlStateNormal];
[forgetpassword setFrame:CGRectMake(100, 450, 100, 30)];
[forgetpassword addTarget:self action:@selector(forgetpasswordclicked:) forControlEvents:UIControlEventTouchUpInside];
forgetpassword.backgroundColor=[UIColor blueColor];
[self.view addSubview:forgetpassword];
//用户名标签
UILabel *userlabel=[[UILabel alloc]initWithFrame:CGRectMake(50, 200, 100, 40)];
userlabel.text=@"用户名";
userlabel.font=[UIFont fontWithName:@"" size:13];
userlabel.backgroundColor=[UIColor yellowColor];
[self.view addSubview:userlabel];
//用户名输入框
UITextField *usertextfield=[[UITextField alloc]initWithFrame:CGRectMake(100, 200, 150, 40)];
usertextfield.secureTextEntry=YES;
usertextfield.autocorrectionType=UITextAutocorrectionTypeNo;
usertextfield.clearsOnBeginEditing=YES;
usertextfield.backgroundColor=[UIColor lightGrayColor];
usertextfield.placeholder=@"请输入用户名";
usertextfield.font=[UIFont fontWithName:@"Arial" size:13];
usertextfield.delegate=self;
[self.view addSubview:usertextfield];
//密码标签
UILabel *passwordlabel=[[UILabel alloc]initWithFrame:CGRectMake(50, 250, 100, 40)];
passwordlabel.text=@" 密码";
passwordlabel.backgroundColor=[UIColor yellowColor];
passwordlabel.font=[UIFont fontWithName:@"" size:13];
[self.view addSubview:passwordlabel];
//密码输入框
UITextField *passwordtextfield=[[UITextField alloc]initWithFrame:CGRectMake(100, 250, 150, 40)];
passwordtextfield.secureTextEntry=YES;
passwordtextfield.autocorrectionType=UITextAutocorrectionTypeNo;
passwordtextfield.clearsOnBeginEditing=YES;
passwordtextfield.backgroundColor=[UIColor lightGrayColor];
passwordtextfield.placeholder=@"请输入密码";
passwordtextfield.font=[UIFont fontWithName:@"arial" size:13];
passwordtextfield.delegate=self;
[self.view addSubview:passwordtextfield];
[super viewDidLoad];
// Do any additional setup after loading the view.
}
-(void)logintouchclicked:(UIButton*)logintouch
{//登陆跳转到主界面按钮
}
-(void)forgetpasswordclicked:(UIButton*)forgetpassword
{ //忘记密码跳转按钮
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
iOS简单的登陆界面代码
最新推荐文章于 2021-02-10 23:48:58 发布