UI简易登陆界面

这篇博客展示了如何使用Objective-C在iOS应用中创建一个简单的登录界面。通过代码详细地描述了如何设置背景视图、标签、输入框以及取消和登录按钮的布局和样式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

.m中部分代码, 模拟简易的登陆界面

    UIView *labelBackground = [[UIView alloc] initWithFrame:CGRectMake(20, 60, 280, 150)];

    [labelBackground setBackgroundColor:[UIColor lightGrayColor]];

    labelBackground.alpha = 0.35;

    [self.window addSubview:labelBackground];

    labelBackground.layer.cornerRadius = 10;

    

    UILabel *enter = [[UILabel alloc] initWithFrame:CGRectMake(40, 20, 60, 20)];

    [enter setBackgroundColor:[UIColor cyanColor]];

    enter.text = @"账号";

    enter.textAlignment = NSTextAlignmentCenter;

    enter.textColor = [UIColor blackColor];

    enter.alpha = 0.7;

    [labelBackground addSubview:enter];

    

    UILabel *secretCode = [[UILabel alloc] initWithFrame:CGRectMake(40, 50, 60, 20)];

    [secretCode setBackgroundColor:[UIColor cyanColor]];

    secretCode.text = @"密码";

    secretCode.textAlignment = NSTextAlignmentCenter;

    secretCode.textColor = [UIColor blackColor];

    [labelBackground addSubview:secretCode];

    

    UITextField *accountNumber = [[UITextField alloc] initWithFrame:CGRectMake(120, 20, 120, 20)];

    [accountNumber setBackgroundColor:[UIColor cyanColor]];

    accountNumber.placeholder = @"请输入账号";

    accountNumber.textAlignment = NSTextAlignmentCenter;

    accountNumber.font = [UIFont systemFontOfSize:15];

    accountNumber.borderStyle = UITextBorderStyleRoundedRect;

    accountNumber.alpha = 0.7;

    [accountNumber setClearsOnBeginEditing:YES];

    [labelBackground addSubview:accountNumber];

    

    UITextField *code = [[UITextField alloc] initWithFrame:CGRectMake(120, 50, 120, 20)];

    [code setBackgroundColor:[UIColor cyanColor]];

    code.placeholder = @"请输入密码";

    code.textAlignment = NSTextAlignmentCenter;

    code.font = [UIFont systemFontOfSize:15];

    code.borderStyle = UITextBorderStyleRoundedRect;

    [code setClearsOnBeginEditing:YES];

    code.secureTextEntry = YES;

    [labelBackground addSubview:code];

    

    UIButton *exit = [UIButton buttonWithType:UIButtonTypeSystem];

    [exit setTitle:@"取消" forState:UIControlStateNormal];

    [exit setBackgroundColor:[UIColor orangeColor]];

    [exit setFrame:CGRectMake(70, 90, 60, 20)];

    [labelBackground addSubview:exit];

    

    UIButton *Enter = [UIButton buttonWithType:UIButtonTypeSystem];

    [Enter setTitle:@"登录" forState:UIControlStateNormal];

    [Enter setBackgroundColor:[UIColor orangeColor]];

    [Enter setFrame:CGRectMake(150, 90, 60, 20)];

    [labelBackground addSubview:Enter];

    

    [labelBackground release];

    [enter release];

    [secretCode release];

    [code release];




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值