iOS简单的登陆界面代码

- (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.
}


转载于:https://www.cnblogs.com/zhuhengjie/p/5966938.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值