「OC」UI练习(一)—— 登陆界面

「OC」登陆界面

明确要求

一个登陆界面的组成,用户名提示以及输入框,密码提示提示以及输入框,登陆按钮,以及注册按钮,根据以上要求我们将我们的组件设置为成员变量。

//viewControl.h
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@property (nonatomic) UILabel *lUserName;
@property (nonatomic) UILabel *lPassword;

@property (nonatomic) UITextField *tsUserName;
@property (nonatomic) UITextField *stPassword;

@property (nonatomic) UIButton *btnLogin;
@property (nonatomic) UIButton *btnRegister;

@end

界面设置

根据以上的组件,我们可以将组件进行编排,代码如下,可根据自身审美进行相关的排版

//viewControl.m
- (void)viewDidLoad {
   
   
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    _lUserName = [[UILabel alloc] initWithFrame:CGRectMake(20, 200, 80, 40)];
    _lUserName.text = @"用户名:";
    _lUserName.font = [UIFont systemFontOfSize:20];
    _lUserName.textAlignment = NSTextAlignmentLeft;
    
    _lPassword = [[UILabel alloc] initWithFrame:CGRectMake(20, 260, 80, 40)];
    _lPassword.text = @"密码:";
    _lPassword.font = [UIFont systemFontOfSize:20];
    _lPassword.textAlignment = NSTextAlignmentLeft;
    
    _tsUserName = [[UITextField alloc] initWithFrame:CGRectMake(120, 200, 180, 40)];
    _tsUserName.placeholder = @"请输入用户名";
    
    _stPassword = [[UITextField alloc] initWithFrame:CGRectMake(120, 260, 180, 40)];
    _stPassword.placeholder = @"请输入密码";
    _stPassword.borderStyle = UITextBorderStyleRoundedRect;
    _stPassword.secureTextEntry = YES;
    
    _btnLogin = [[UIButton alloc] initWithFrame:CGRectMake(100, 400, 80, 40)];
    _btnLogin.backgroundColor = [UIColor redColor];
    [_btnLogin setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [_btnLogin setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    [_btnLogin setTitle:@"登录" forState:UIControlStateNormal
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值