用UI简单的控件搭载一个简单的登录页面

******由于是初学者,很多代码都还没有优化.所以此代码仅供参考:

- (void)viewDidLoad {

    [super viewDidLoad];

   //导入背景色

    //设定背景色的尺寸

   self.ImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];

    //设置背景色图片

    self.ImageView.image =[UIImage imageNamed:@"beijing.png"];

    //添加背景色图片到父视图上

        [self.view addSubview:self.ImageView];

    

    //输入WELCOME

    //定义lable的大小

    self.labe1 = [[UILabel alloc] initWithFrame:CGRectMake((self.view.frame.size.width-200)/2, 30, 200, 50)];

    //给lable1赋值

    self.labe1.text = @"WELCOME";

    self.labe1.font = [UIFont fontWithName:@"Symbol"size:1];

    NSLog(@"%@",[UIFont familyNames]);

    //让书签居中

    self.labe1.textAlignment = NSTextAlignmentCenter;

    self.labe1.shadowColor = [UIColor brownColor];

    self.labe1.shadowOffset = CGSizeMake(5, 5);

    //给书签设定背景色

    self.labe1.textColor = [UIColor whiteColor];

    //设定书签字体的大小

    self.labe1.font = [UIFont systemFontOfSize:35 weight:5];

    //显示书签

    [self.view addSubview:self.labe1];

    

    //导入用户名头像

    //设置头像的位置

    self.ImageView2 = [[UIImageView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width-200)/2-30, 95,25,30)];

    //导入头像

    self.ImageView2.image = [UIImage imageNamed:@"phoneIcon@2x.png"];

    //显示头像

    [self.view addSubview:self.ImageView2];

    

    //输入账号设置

    self.field1 = [[UITextField alloc ]initWithFrame:CGRectMake((self.view.frame.size.width-200)/2, 90, 200, 40)];

    //设置用户提示栏

    self.field1.text =@"请输入手机号";

   // 设置字体的颜色及透明度

    self.field1.textColor = [UIColor colorWithWhite:1.0 alpha:0.5];

    //显示用户栏

    [self.view addSubview:self.field1];

    

    //导入登陆白线

    self.alable =[[UILabel alloc] initWithFrame:CGRectMake((self.view.bounds.size.width-200)/2-30, 132, 230, 1)];

    //设置线的颜色

    self.alable.backgroundColor =[UIColor whiteColor];

    [self.view addSubview:self.alable];

    

    //导入安全锁

    self.ImageView3 = [[UIImageView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width-200)/2-30, 140,25,30)];

    //导入锁的图标

    self.ImageView3.image = [UIImage imageNamed:@"passwordIcon@2x.png"];

    //显示锁的图标

    [self.view addSubview:self.ImageView3];

    

    // 输入密码设置

    self.field2 = [[UITextField alloc ]initWithFrame:CGRectMake((self.view.frame.size.width-200)/2, 135, 200, 40)];

    self.field2.text =@"请输入密码";

    // 设置字体的颜色及透明度

    self.field2.textColor = [UIColor colorWithWhite:1.0 alpha:0.5];

    [self.view addSubview:self.field2];

    

    //导入注册白线

    self.alable =[[UILabel alloc] initWithFrame:CGRectMake((self.view.bounds.size.width-200)/2-30, 176, 230, 1)];

    self.alable.backgroundColor =[UIColor whiteColor];

    [self.view addSubview:self.alable];

    

    //登录按键设置

    //设置登录按键的大小

    self.button = [[UIButton alloc] initWithFrame:CGRectMake((self.view.frame.size.width-250)/2, 200, 250, 40)];

    //按钮的圆角

   self.button.layer.cornerRadius = 10;

      //设置按钮的背景色

   self.button.backgroundColor = [UIColor colorWithRed:0.3 green:0.6 blue:0.5 alpha:1.0];

   // self.button.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"loginButton@2x.png"]];

    //设置登录的提示字

    [self.button setTitle:@"登录" forState:UIControlStateNormal];

    //设置字体的大小

    self.button.titleLabel.font = [UIFont systemFontOfSize:20 weight:2];

    //显示登录按钮

    [self.view addSubview:self.button];

    //注册按键设置

    self.button1 = [[UIButton alloc] initWithFrame:CGRectMake((self.view.frame.size.width-250)/2, 250, 250, 40)];

    //设置按钮圆角

     self.button1.layer.cornerRadius = 10;

    //设置背景色

    self.button1.backgroundColor = [UIColor whiteColor];

    //设置注册的提示字

    [self.button1 setTitle:@"注册" forState:UIControlStateNormal];

    //设置字体的颜色

    [self.button1 setTitleColor:[UIColor colorWithRed:0.3 green:0.6 blue:0.5 alpha:1.0] forState: UIControlStateNormal];

    //设置字体的大小

    self.button1.titleLabel.font = [UIFont systemFontOfSize:20 weight:1];

    [self.view addSubview:self.button1];

 

    //导入学啊网logo

    self.ImageView1 = [[UIImageView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width-80)/2, self.view.bounds.size.height-50,80,20)];

    //导入logo@2x.png图片

    self.ImageView1.image = [UIImage imageNamed:@"logo@2x.png"];

    [self.view addSubview:self.ImageView1];

    

 

}

 

转载于:https://www.cnblogs.com/liumu/p/5252140.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值