码迷,mamicode.com
首页 > 移动开发 > 详细

iOS--APP 登录界面图(xuer)

时间:2016-03-07 22:18:37      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:

ViewController.h 


 

#import "ViewController.h"

@interface ViewController ()

@property(strong,nonatomic)UIImageView *beijing;
@property(strong,nonatomic) UIImageView *welcome;
@property(strong,nonatomic) UIImageView *phoneIcon;
@property(strong,nonatomic)UITextField *Intele;
@property(strong,nonatomic) UIView *InteleView;
@property(strong,nonatomic) UIImageView *passwordIcon;
@property(strong,nonatomic) UITextField *Inpassword;
@property(strong,nonatomic) UIView *InpasswordView;
@property(strong,nonatomic) UIImageView *logo;
@property(strong,nonatomic) UIButton *loginButton;
@property(strong,nonatomic) UIButton *rigisterButton;

@end

 

ViewController.m


@implementation ViewController

- (void)viewDidLoad {
        [super viewDidLoad];
    // 添加父视图beijing背景图
    self.beijing=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    //  插入图片
    [self.beijing setImage:[UIImage imageNamed:@"beijing"]];
    [self.view addSubview:self.beijing];
    
    //  添加子视图welcome背景图
    self.welcome=[[UIImageView alloc] initWithFrame:CGRectMake(57, 36, 318, 58)];
    //  插入图片
    [self.welcome setImage:[UIImage imageNamed:@"welcome"]];
    //  插入子视图
    [self.view addSubview:self.welcome];
    
    
    // 添加phoneIcon输入图标
    self.phoneIcon=[[UIImageView alloc] initWithFrame:CGRectMake(66, 122, 25, 30)];
    //  插入图片
    [self.phoneIcon setImage:[UIImage imageNamed:@"phoneIcon"]];
    [self.view addSubview:self.phoneIcon];
    
    // 添加手机号码输入框
    self.Intele=[[UITextField alloc] initWithFrame:CGRectMake(99, 122, 267, 40)];
    // 设置隐身字
    self.Intele.placeholder=@"请输入手机号码";
    //  设置数字弹出键盘
    self.Intele.keyboardType=UIKeyboardTypeNumberPad;
    // 设置无边框的UITextField
    self.Intele.borderStyle=UITextBorderStyleNone;
    [self.view addSubview:self.Intele];
    self.InteleView=[[UIView alloc] initWithFrame:CGRectMake(66, 160, 300, 1)];
    self.InteleView.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:self.InteleView];
    
    
    // 添加密码输入框
    self.Inpassword=[[UITextField alloc] initWithFrame:CGRectMake(99, 182, 267, 40)];
    self.Inpassword.placeholder=@"请输入密码";
    self.Inpassword.secureTextEntry=YES;
    self.Inpassword.borderStyle=UITextBorderStyleNone;
    [self.view addSubview:self.Inpassword];
    
    self.InpasswordView=[[UIView alloc] initWithFrame:CGRectMake(66, 213, 300, 1)];
    self.InpasswordView.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:self.InpasswordView];
    
    // 添加passwordIcon输入图标
    self.passwordIcon=[[UIImageView alloc] initWithFrame:CGRectMake(66, 182, 25, 30)];
    [self.passwordIcon setImage:[UIImage imageNamed:@"passwordIcon"]];
    [self.view addSubview:self.passwordIcon];
    
    //  添加logo背景图
    self.logo=[[UIImageView alloc] initWithFrame:CGRectMake(173, 694, 69, 22)];
    [self.logo setImage:[UIImage imageNamed:@"logo"]];
    [self.view addSubview:self.logo];
    
    //  登录按钮的相关设置
    self.loginButton=[[UIButton alloc] initWithFrame:CGRectMake(66, 282, 318, 50)];
    [self.loginButton setBackgroundImage:[UIImage imageNamed:@"loginButton"] forState:UIControlStateNormal];
    [self.loginButton setTitle:@"登录" forState:UIControlStateNormal];
    //  事件监听
    [self.loginButton addTarget:self action:@selector(hideKeyBoard) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.loginButton];
    
    // 注册按钮的相关设置
    self.rigisterButton=[[UIButton alloc] initWithFrame:CGRectMake(66, 338, 318, 50)];
    [self.rigisterButton setBackgroundImage:[UIImage imageNamed:@"rigisterButton"] forState:UIControlStateNormal];
    [self.rigisterButton setTitle:@"注册" forState:UIControlStateNormal];
    
    //  事件监听
    [self.rigisterButton addTarget:self action:@selector(hideKeyBoard) forControlEvents:UIControlEventTouchUpInside];
    [self.rigisterButton setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
    [self.view addSubview:self.rigisterButton];
    
}
// 点击空白区域  隐藏键盘
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self hideKeyBoard];
}

-(void)hideKeyBoard
{
    if ([self.Intele isFirstResponder]||[self.Inpassword isFirstResponder]){
        [self.Intele resignFirstResponder];
        [self.Inpassword resignFirstResponder];
    }
    
}

运行结果:

技术分享 

 

iOS--APP 登录界面图(xuer)

标签:

原文地址:http://www.cnblogs.com/bolin-123/p/5252030.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!