这个登录页面包含了自适应屏幕的大小,数字用户登录键盘是数字键盘、隐藏键盘、隐藏密码等等。

ViewController.h


#import <UIKit/UIKit.h>
#import "UIViewExt.h"
@interface ViewController : UIViewController<UITextFieldDelegate>
/**
* 背景图片
*/
@property(strong,nonatomic) UIImageView *Imagebackgroud;
/**
* 用户名输入框
*/
@property(strong,nonatomic) UITextField *NameTextfild;
/**
* 密码输入框
*/
@property(strong,nonatomic) UITextField *PasswordTextfild;
/**
* 登录按钮
*/
@property(strong,nonatomic) UIButton *LoginButton;
/**
* 注册按钮
*/
@property(strong,nonatomic) UIButton *RegistrationButton; @end

ViewController.m


#import "ViewController.h"
#define WIDTH self.view.width
#define HEIGHT self.view.height @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
[self setBackgroudImage];
[self setLoginImage];
[self setTextFiled];
[self setButton];
}
#pragma Mark - 设置背景图的方法
-(void)setBackgroudImage
{
self.Imagebackgroud=[[UIImageView alloc] initWithFrame:self.view.frame];
[self.Imagebackgroud setImage:[UIImage imageNamed:@"beijing"]];
[self.view addSubview:self.Imagebackgroud];
} #pragma Mark - 设置输入框
-(void)setTextFiled
{
// 用户名输入框设置
self.NameTextfild=[[UITextField alloc] initWithFrame:CGRectMake(WIDTH *0.1, HEIGHT *0.2, WIDTH*0.8, HEIGHT*0.05)];
self.NameTextfild.backgroundColor=[UIColor clearColor];
self.NameTextfild.placeholder=@"请输入手机号";
// 设置输入键盘为数字键盘
self.NameTextfild.keyboardType=UIKeyboardTypeNumberPad;
// 设置输入框内的图标 默认为不显示
self.NameTextfild.leftView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"phoneIcon"]];
self.NameTextfild.leftViewMode=UITextFieldViewModeAlways;
[self.view addSubview:self.NameTextfild];
// 设置用户名输入框下的线
UIView *Nameview=[[UIView alloc]initWithFrame:CGRectMake(WIDTH *0.1, HEIGHT *0.2+HEIGHT*0.05,WIDTH*0.8, )];
Nameview.backgroundColor=[UIColor whiteColor];
[self.view addSubview:Nameview]; // 密码输入框设置
self.PasswordTextfild=[[UITextField alloc] initWithFrame:CGRectMake(WIDTH *0.1,HEIGHT*0.2+HEIGHT*0.06, WIDTH*0.8, HEIGHT*0.05)];
self.PasswordTextfild.backgroundColor=[UIColor clearColor];
self.PasswordTextfild.placeholder=@"请输入密码";
// 设置输入密码保护(隐藏密码)
self.PasswordTextfild.secureTextEntry=YES;
// 设置单击return隐藏键盘需要代理
self.PasswordTextfild.delegate=self;
// 设置输入框内的图标 默认为不显示
self.PasswordTextfild.leftView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"passwordIcon"]];
self.PasswordTextfild.leftViewMode=UITextFieldViewModeAlways;
[self.view addSubview:self.PasswordTextfild];
// 设置密码输入框下的线
UIView *Passwordview=[[UIView alloc]initWithFrame:CGRectMake(WIDTH *0.1,HEIGHT*0.31,WIDTH*0.8, )];
Passwordview.backgroundColor=[UIColor whiteColor];
[self.view addSubview:Passwordview];
} #pragma Mark -按钮设置方法
-(void)setButton
{
// 登录按钮设置
self.LoginButton=[[UIButton alloc] initWithFrame:CGRectMake(WIDTH *0.1, HEIGHT*0.35, WIDTH *0.8, HEIGHT * 0.08)];
[self.LoginButton setBackgroundImage:[UIImage imageNamed:@"loginButton"] forState:UIControlStateNormal];
[self.LoginButton setTitle:@"登录" forState:UIControlStateNormal];
[self.view addSubview:self.LoginButton]; // 注册按钮设置
self.RegistrationButton=[[UIButton alloc] initWithFrame:CGRectMake(WIDTH *0.1, HEIGHT * 0.45, WIDTH *0.8, HEIGHT * 0.08)];
[self.RegistrationButton setBackgroundImage:[UIImage imageNamed:@"rigisterButton"] forState:UIControlStateNormal];
[self.RegistrationButton setTitle:@"注册" forState:UIControlStateNormal];
[self.RegistrationButton setTitleColor:[UIColor colorWithRed:0.115 green:0.749 blue:0.769 alpha:1.000] forState:UIControlStateNormal];
[self.view addSubview:self.RegistrationButton]; } #pragma Mark - logo图片设置
-(void)setLoginImage
{
// 欢迎图片设置
UIImageView *welcomeView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"welcome"]];
welcomeView.frame=CGRectMake(WIDTH *0.1, HEIGHT*0.05, WIDTH *0.8, HEIGHT *0.08);
[self.view addSubview:welcomeView]; // logo图片设置
UIImageView *LogoView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo"]];
LogoView.frame=CGRectMake(WIDTH*0.4, HEIGHT-HEIGHT*0.08, WIDTH*0.2, HEIGHT*0.03);
[self.view addSubview:LogoView]; }
#pragma Mark - 设置键盘的隐藏
/**
* 单击空白处隐藏键盘
*
* @param touches 空白处
* @param event 单击
*/
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
if ([self.NameTextfild isFirstResponder]||[self.PasswordTextfild isFirstResponder]) {
[self.NameTextfild resignFirstResponder];
[self.PasswordTextfild resignFirstResponder];
}
} /**
* 单击return隐藏键盘
*/
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[self.PasswordTextfild resignFirstResponder];
return YES;
}
...
@end

运行效果图:

2016-04-06 22:22:01

iOS--xuer(registration)的更多相关文章

  1. iOS开发(OC)中的命名规范

    开小差:最近发现自己有一个经验主义的毛病,不太容易接受新的知识,这对从事技术研发的人来说不太合理,需要改之. 正文:通过读写大量代码我有自己的一套编程思路和习惯,自认为自己的编码习惯还是不错的,代码结 ...

  2. XMPPFrameWork IOS 开发(六)聊天室

    原始地址:XMPPFrameWork IOS 开发(六)聊天室 聊天室 //初始化聊天室 XMPPJID *roomJID = [XMPPJID jidWithString:ROOM_JID]; xm ...

  3. XMPPFrameWork IOS 开发(一)xmpp简介

    原始地址:XMPPFrameWork IOS 开发(一) XMPP : The Extensible Messaging and Presence Protocol 中文全称: 可扩展通讯和表示协议 ...

  4. XMPPFrameWork IOS 开发(二)- xcode配置

    原始地址:XMPPFrameWork IOS 开发(二) 译文地址:   Getting started using XMPPFramework on iOS 介绍 ios上的XMPPFramewor ...

  5. 深度图像配准(Registration)原理

    机器视觉中,3D相机产生的深度图像(depth image)通常需要配准(registration),以生成配准深度图像(registed depth image).实际上配准的目的就是想让深度图和彩 ...

  6. XMPPFrameWork IOS 开发(四)消息和好友上下线

    原始地址:XMPPFrameWork IOS 开发(四) 消息 //收到消息 - (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XM ...

  7. XMPPFrameWork IOS 开发(三)登录

    原始地址:XMPPFrameWork IOS 开发(三) XMPP中常用对象们: XMPPStream:xmpp基础服务类 XMPPRoster:好友列表类 XMPPRosterCoreDataSto ...

  8. XE6移动开发环境搭建之IOS篇(7):在Mac OSX 10.8中安装XE6的PAServer(有图有真相)

    XE6移动开发环境搭建之IOS篇(7):在Mac OSX 10.8中安装XE6的PAServer(有图有真相) 2014-08-22 21:06 网上能找到的关于Delphi XE系列的移动开发环境的 ...

  9. XE6移动开发环境搭建之IOS篇(2):安装虚拟机(有图有真相)

    XE6移动开发环境搭建之IOS篇(2):安装虚拟机(有图有真相) 2014-08-15 22:04 网上能找到的关于Delphi XE系列的移动开发环境的相关文章甚少,本文尽量以详细的内容.傻瓜式的表 ...

  10. iOS逆向(五)-ipa包重签名

    为什么要重签名? 1.在没有源代码的情况下,你已经对某个应用进行了资源修改(比如修改了启动图或图标等).修改完成以后,如果想要让APP可以正常使用,该APP一定要重新签名然后压缩成IPA文件. 2.如 ...

随机推荐

  1. windows server 注意windows的temp目录

    windows解压缩包.安装软件时,会生成一些临时文件存放在temp目录中,windows不会自动删除这些文件. 临时文件目录可以在环境变量中查看和配置 在工作机or个人PC机中中这个目录一般不会有什 ...

  2. swift中Range的使用书名

    在swift中Range有两种用法 1.把字符串转换成NSString来使用 //这里是把swift的字符换转换成了nsstring 使用 let str :NSString = text.strin ...

  3. 在博客中使用LaTeX插入数学公式

    在博客中使用LaTeX插入数学公式 在学习机器学习中会接触到大量的数学公式,所以在写博客是会非常的麻烦.用公式编辑器一个一个写会非常的麻烦,这时候我们可以使用LaTeX来插入公式. 写这篇博文的目的在 ...

  4. 附录D 安装ZooKeeper

    D.1    安装ZooKeeper D.1.1   下载ZooKeeper ZooKeeper是Apache基金会的一个开源.分布式应用程序协调服务,是Google的Chubby一个开源的实现.它是 ...

  5. 解决ajax跨域请求 (总结)

    ajax跨域请求,目前已用几种方法实现:   1)用原生js的xhr对象实现.                var url="http://freegeoip.net/json/" ...

  6. 【JUC】JDK1.8源码分析之CountDownLatch(五)

    一.前言 分析完了CyclicBarrier后,下面分析CountDownLatch,CountDownLatch用于同步一个或多个任务,强制他们等待由其他任务执行的一组操作完成.CountDownL ...

  7. 自定义angularjs分页控件

    继昨天写了knockoutjs+ jquery pagination+asp.net web Api 实现无刷新列表页 ,正好最近刚学习angularjs ,故琢磨着写一个angularjs版本的分页 ...

  8. 工作流引擎Oozie(二):coordinator

    1. 简介 coordinator是workflow的定时提交器,基于时间条件与数据生成触发(based on time and data triggers).简单点说,coordinator按所定义 ...

  9. Net设计模式实例之简单工厂模式(Simple Factory Pattern)

    一.简单工厂模式简介(Bref Introduction) 简单工厂模式(Simple Factory Pattern)的优点是,工厂类中包含了必要的逻辑判断,根据客户端的选择条件动态实例化相关的类, ...

  10. C#学习记录

    转眼几个月没更博了,把几个月前学C#的笔记发一下,就记录了点教重要的点子而已 1.打印 Console.WriteLine(); 打印 Console.ReadKey(); 按一个按键继续执行 Con ...