iOS--xuer(registration)
这个登录页面包含了自适应屏幕的大小,数字用户登录键盘是数字键盘、隐藏键盘、隐藏密码等等。
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)的更多相关文章
- iOS开发(OC)中的命名规范
开小差:最近发现自己有一个经验主义的毛病,不太容易接受新的知识,这对从事技术研发的人来说不太合理,需要改之. 正文:通过读写大量代码我有自己的一套编程思路和习惯,自认为自己的编码习惯还是不错的,代码结 ...
- XMPPFrameWork IOS 开发(六)聊天室
原始地址:XMPPFrameWork IOS 开发(六)聊天室 聊天室 //初始化聊天室 XMPPJID *roomJID = [XMPPJID jidWithString:ROOM_JID]; xm ...
- XMPPFrameWork IOS 开发(一)xmpp简介
原始地址:XMPPFrameWork IOS 开发(一) XMPP : The Extensible Messaging and Presence Protocol 中文全称: 可扩展通讯和表示协议 ...
- XMPPFrameWork IOS 开发(二)- xcode配置
原始地址:XMPPFrameWork IOS 开发(二) 译文地址: Getting started using XMPPFramework on iOS 介绍 ios上的XMPPFramewor ...
- 深度图像配准(Registration)原理
机器视觉中,3D相机产生的深度图像(depth image)通常需要配准(registration),以生成配准深度图像(registed depth image).实际上配准的目的就是想让深度图和彩 ...
- XMPPFrameWork IOS 开发(四)消息和好友上下线
原始地址:XMPPFrameWork IOS 开发(四) 消息 //收到消息 - (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XM ...
- XMPPFrameWork IOS 开发(三)登录
原始地址:XMPPFrameWork IOS 开发(三) XMPP中常用对象们: XMPPStream:xmpp基础服务类 XMPPRoster:好友列表类 XMPPRosterCoreDataSto ...
- 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系列的移动开发环境的 ...
- XE6移动开发环境搭建之IOS篇(2):安装虚拟机(有图有真相)
XE6移动开发环境搭建之IOS篇(2):安装虚拟机(有图有真相) 2014-08-15 22:04 网上能找到的关于Delphi XE系列的移动开发环境的相关文章甚少,本文尽量以详细的内容.傻瓜式的表 ...
- iOS逆向(五)-ipa包重签名
为什么要重签名? 1.在没有源代码的情况下,你已经对某个应用进行了资源修改(比如修改了启动图或图标等).修改完成以后,如果想要让APP可以正常使用,该APP一定要重新签名然后压缩成IPA文件. 2.如 ...
随机推荐
- Android okHttp网络请求之Get/Post请求
前言: 之前项目中一直使用的Xutils开源框架,从xutils 2.1.5版本使用到最近的xutils 3.0,使用起来也是蛮方便的,只不过最近想着完善一下app中使用的开源框架,由于Xutils里 ...
- Android okHttp网络请求之缓存控制Cache-Control
前言: 前面的学习基本上已经可以完成开发需求了,但是在项目中有时会遇到对请求做个缓存,当没网络的时候优先加载本地缓存,基于这个需求我们来学习一直okHttp的Cache-Control. okHttp ...
- 5分钟用Spring4 搭建一个REST WebService
前置技能 ① 使用maven来管理java项目 这个技能必须点一级,以便快速配置项目. 本文实际上是我学习Spring的过程中搬的官网上的demo,使用maven配置项目. ② jdk 1.8+ ...
- 扩展KMP算法
一 问题定义 给定母串S和子串T,定义n为母串S的长度,m为子串T的长度,suffix[i]为第i个字符开始的母串S的后缀子串,extend[i]为suffix[i]与字串T的最长公共前缀长度.求出所 ...
- 十进制(decimal system)转换函数说明
一,十进制(decimal system)转换函数说明 1,十进制转二进制 decbin() 函数,如下实例 echo decbin(12); //输出 1100 echo decbin(26); / ...
- 谈谈JIT编译器和本机影像生成器(NGen.exe)
前言 在看<CLR>的时候,作者在开篇的时候提到了NGen.exe,前面一节执行程序集的代码中提到:程序或方法执行前会执行MSCorEE.dll中的JIT函数把要执行方法的IL转换成本地的 ...
- geotrellis使用(九)使用geotrellis进行栅格渲染
目录 前言 图像渲染 总结 参考链接 一.前言 前面几篇文章讲解了如何使用Geotrellis进行数据处理.瓦片生成等,今天主要表一下如何使用Geotrellis进行栅格渲染. ...
- sublime3破解版sublime3注册码
Sublime Text 3 官方网址:http://www.sublimetext.com/ Mac下载地址: http://c758482.r82.cf2.rackcdn.com/Sublime% ...
- Introduction to the Service Provider Interfaces--官方文档
地址:https://docs.oracle.com/javase/tutorial/sound/SPI-intro.html What Are Services? Services are unit ...
- 虚拟机利用Host-only实现在不插网线的情况下,虚拟机与主机实现双向通信,实现ssh连接以及samba服务实现共享
为了不影响其他的虚拟网卡,我们在VMware下在添加一块虚拟网卡: 然后点击Next,选择连接方式: 点击Finish即可. 重新启动虚拟机,如果这是你手动添加的第一块虚拟网卡,那么应该是eth1. ...