//

//  ViewController.m

//  QQUI_bydfg

//

//  Created by Kevin_dfg on 16/4/15.

//  Copyright © 2016年 kevin_dfg. All rights reserved.

//

#import "ViewController.h"

//图片选择器协议

@interface ViewController () <UINavigationControllerDelegate, UIImagePickerControllerDelegate>

//**************************设置控件的坐标*********************************

//屏幕宽高

#define screenWidth   self.view.frame.size.width

#define screenHeight   self.view.frame.size.height

//qq头像宽高

#define qqY   80

#define qqW   0.25*screenWidth

#define qqX   (screenWidth - qqW)/2

#define qqH   qqW

//账号

#define accountX   0

#define accountY   qqY+qqH+20

#define accountW   screenWidth

#define accountH   50

//密码

#define passwdX   0

#define passwdY   accountY+accountH+20

#define passwdW   screenWidth

#define passwdH    30

//登陆按钮

#define loginX    35

#define loginY    passwdY+passwdH+20

#define loginW    screenWidth-2*loginX

#define loginH    50

//登陆失败

#define failedX   10

#define failedY   0.95*screenHeight

#define failedW    80

#define failedH    25

//注册用户按钮

#define newX     0.8*screenWidth

#define newY     0.95*screenHeight

#define newW     80

#define newH     25

//************声明头像,密码,登陆失败,注册用户*********************************

@property(nonatomic,strong)UIButton *headBtn ;

@property(nonatomic,strong)UIButton *loginBtn;

@property(nonatomic,strong)UIButton *failedBtn ;

@property(nonatomic,strong)UIButton *signBtn;

@property(nonatomic,strong)UITextField *account, *passwd;

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

//*****************************qq头像******************************

//分配初始化qq头像按钮

self.headBtn =[[UIButton alloc]initWithFrame:CGRectMake(qqX, qqY, qqW, qqH)];

//设置qq头像

[_headBtn setBackgroundImage:[UIImage imageNamed:@"head.jpg" ] forState:UIControlStateNormal];

//添加图层蒙版,圆角化

_headBtn.layer.cornerRadius=qqH/2;

_headBtn.layer.masksToBounds=YES;

[_headBtn addTarget:self action:@selector(changHeadAction:) forControlEvents:UIControlEventTouchUpInside];

//添加头像按钮到视图

[self.view addSubview:_headBtn];

//****************************账户和密码控件*****************************

//分配初始化账户和密码按钮

_account =[[UITextField alloc]initWithFrame:CGRectMake(accountX, accountY, accountW, accountH)];

_passwd =[[UITextField alloc]initWithFrame:CGRectMake(passwdX, passwdY, passwdW, passwdH)];

//设置账户的背景图片

[_account setBackground:[UIImage imageNamed:@"login_textfield.png"]];

//设置账户和密码的属性:居中,数字键盘,提示符

_account.textAlignment=NSTextAlignmentCenter;

_account.keyboardType=UIKeyboardTypeNumberPad;

_account.placeholder=@"qq号/手机号/邮箱";

_passwd.textAlignment=NSTextAlignmentCenter;

_passwd.keyboardType=UIKeyboardTypeAlphabet;

_passwd.placeholder=@"qq密码";

//设置密码的密文显示

_passwd.secureTextEntry=YES;

[self.view addSubview:_account];

[self.view addSubview:_passwd];

//**************************登陆按钮*********************************

//分配初始化登陆按钮

_loginBtn=[[UIButton alloc]initWithFrame:CGRectMake(loginX, loginY, loginW, loginH)];

//设置登陆按钮的效果

[_loginBtn setBackgroundImage:[UIImage imageNamed:@"loginBtn_nor.png"] forState:UIControlStateNormal];

[_loginBtn setBackgroundImage:[UIImage imageNamed:@"loginBtn_h.png"] forState:UIControlStateHighlighted];

//为登陆按钮设置监听事件

[_loginBtn addTarget:self action:@selector(loginAction:) forControlEvents:UIControlEventTouchUpInside];

//将登陆按钮添加到视图

[self.view addSubview:_loginBtn];

//**************************登陆失败按钮*********************************

//分配初始化登陆失败按钮

_failedBtn =[[UIButton alloc]initWithFrame:CGRectMake(failedX, failedY, failedW, 25)];

//设置登陆失败按钮的效果

[_failedBtn setBackgroundImage:[UIImage imageNamed:@"failed.png"] forState:UIControlStateNormal];

[_failedBtn setBackgroundImage:[UIImage imageNamed:@"failed.png"] forState:UIControlStateHighlighted];

//为登陆失败按钮设置监听事件

[_failedBtn addTarget:self action:@selector(failedAction:) forControlEvents:UIControlEventTouchUpInside];

//将登陆失败按钮添加到视图

[self.view addSubview:_failedBtn];

//***********************新用户注册按钮*********************************

//分配初始化新用户注册按钮

_signBtn =[[UIButton alloc]initWithFrame:CGRectMake(newX , newY, newW, newH)];

//设置新用户注册按钮的效果

[_signBtn setBackgroundImage:[UIImage imageNamed:@"new.png"] forState:UIControlStateNormal];

[_signBtn setBackgroundImage:[UIImage imageNamed:@"new.png"] forState:UIControlStateHighlighted];

//为新用户注册按钮设置监听事件

[_signBtn addTarget:self action:@selector(signAction:) forControlEvents:UIControlEventTouchUpInside];

//将新用户注册按钮添加到视图

[self.view addSubview:_signBtn];

}

//**************************************改变头像事件***************************************

-(void)changHeadAction:(UIButton *)headBtn{

//分配初始化图片选择器

UIImagePickerController *picker=[[UIImagePickerController alloc] init];

//设置图片来源:系统相册

picker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;

//为图片选择器设置委托事件

picker.delegate=self;

//模态窗口显示图片选择器

[self presentViewController:picker animated:YES completion:nil];

}

//**************************图片选择器委托事件*********************************

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(nullable NSDictionary<NSString *,id> *)editingInfo{

//选择系统相册里的图片当头像

[_headBtn setBackgroundImage:image forState:UIControlStateNormal];

//退出模态窗口

[picker dismissViewControllerAnimated:YES completion:nil];

}

//**************************登陆按钮事件*********************************

-(void)loginAction:(UIButton *)loginBtn{

//判断账号和密码是否为空

if (_account.text.length >0 &&_passwd.text.length >0) {

//分配初始化提示控制窗口

UIAlertController *alert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"账号:%@",_account.text]  message:[NSString stringWithFormat:@"密码:%@",_passwd.text] preferredStyle:UIAlertControllerStyleAlert];

//将确定按钮添加到提示框内

[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];

//模态窗口显示提示窗

[self presentViewController:alert animated:YES completion:nil];

}else{

//分配初始化提示控制窗口

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"错误" message:@"用户或密码不能为空" preferredStyle:UIAlertControllerStyleAlert];

//将确定按钮添加到提示框内

[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];

//模态窗口显示提示窗

[self presentViewController:alert animated:YES completion:nil];

}

}

//*************************登陆失败事件**********************************

-(void)failedAction:(UIButton *)failedBtn{

//分配初始化提示控制窗口

UIAlertController *alert= [UIAlertController alertControllerWithTitle:@"找回密码" message:@"短信登陆" preferredStyle:UIAlertControllerStyleActionSheet];

//将确定按钮添加到提示框内

[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];

//模态窗口显示提示窗

[self presentViewController:alert animated:YES completion:nil];

}

//**************************新用户注册事件*********************************

-(void)signAction:(UIButton *)signBtn{

//分配初始化提示控制窗口

UIAlertController *alert= [UIAlertController alertControllerWithTitle:@"验证手机号码" message:@"中国 +86 " preferredStyle:UIAlertControllerStyleActionSheet];

//将确定按钮添加到提示框内

[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];

//模态窗口显示提示窗

[self presentViewController:alert animated:YES completion:nil];

}

@end

IOS 开发qq登陆界面的更多相关文章

  1. [iOS基础控件 - 3.1] QQ登陆界面

      A.storyboard 控件版 1.label 2.textfield      a.Keyboard Type           账号:Number Pad           密码:Num ...

  2. WPF和Expression Blend开发实例:模拟QQ登陆界面打开和关闭特效

    不管在消费者的心中腾讯是一个怎么样的模仿者抄袭者的形象,但是腾讯在软件交互上的设计一直是一流的.正如某位已故的知名产品经理所说的:设计并非外观怎样,感觉如何.设计的是产品的工作原理.我觉得腾讯掌握了其 ...

  3. IOS开发之记录用户登陆状态,ios开发用户登陆

    IOS开发之记录用户登陆状态,ios开发用户登陆 上一篇博客中提到了用CoreData来进行数据的持久化,CoreData的配置和使用步骤还是挺复杂的.但熟悉CoreData的使用流程后,CoreDa ...

  4. 用户登陆状态,ios开发用户登陆

    IOS开发之记录用户登陆状态,ios开发用户登陆 上一篇博客中提到了用CoreData来进行数据的持久 化,CoreData的配置和使用步骤还是挺复杂的.但熟悉CoreData的使用流程后,CoreD ...

  5. iOS开发 QQ粘性动画效果

    QQ(iOS)客户端的粘性动画效果 时间 2016-02-17 16:50:00  博客园精华区 原文  http://www.cnblogs.com/ziyi--caolu/p/5195615.ht ...

  6. Qt 之 模仿 QQ登陆界面——样式篇

    一.简述 今天晚上花了半天时间从QQ登录界面抠了些图,顺便加了点样式基本上实现了QQ的登陆界面全部效果.虽不说100%相似,那也有99.99%相似了哈O(∩_∩)O. QQ好像从去年开始,登录界面有了 ...

  7. ios swift模仿qq登陆界面,xml布局

    给大家推荐两个学习的地址: 极客学院的视频:http://www.jikexueyuan.com/path/ios/ 一个博客:http://blog.csdn.net/lizhongfu2013/a ...

  8. iOS开发--QQ音乐练习,后台播放和锁屏界面

    一.设置后台播放 首先允许程序后台播放 代码实现 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOpti ...

  9. [UI基础][QQ登陆界面]

    [目标] 1.QQ号码文本框要有“请输入QQ号码”的提示(用户输入时会自动消失) 2.QQ密码文本框要有“请输入QQ密码”的提示(用户输入文字会自动消失) 3.QQ号码文本框只能输入数字 4.QQ密码 ...

随机推荐

  1. Windows Azure上搭建SSTP VPN

    一.服务器设置 首先,从0开始,你需要创建一个新的VM.我选择Windows Server 2012 R2,所有步骤和创建普通VM都一样,但最后在防火墙设置里一定要打开TCP 443端口: 创建完成后 ...

  2. Objective-C中NSValue的使用

    我们在C/C++开发中常会用到结构体来帮助我们简单封装基本数据类型,在Objective-C中我们也可以使用结构体来完成数据类型的封装.同时,Cocoa Touch还提供了一个NSValue来帮助我们 ...

  3. Oracle数据库DECODE函数的使用.

    decode函数是Oracle数据库独有的. 语法为: decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值) 例子:select decode(sign(变量1-变量2) ...

  4. php中ckeditor(Fckeditor)的配置方法

    ckeditor 编辑器php正确配置方法 1. 下载安装 CKEditor: http://ckeditor.com/ 解压下载到的CKEditor放到网站的路径中即可 2. 下载安装 CKFind ...

  5. IOS开发在线文档 记录下

    View Programming Guide for iOS https://developer.apple.com/library/prerelease/ios/documentation/UIKi ...

  6. 让所有浏览器包括IE6即支持最大宽度又支持最小宽度。

    让所有浏览器包括IE6即支持最大宽度又支持最小宽度. _height  _width:针对ie6 css hack .yangshi{max-width:620px;min-width:1px;_wi ...

  7. iis6.0+.net 4.0 +mvc 404错误

    ps: 在iis中重新注册.net framework命令cd C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i 1 ...

  8. 第一个Sprint冲刺第四天

    讨论成员:邵家文.李新.朱浩龙.陈俊金 讨论问题:掌握计时技术的知识 讨论地点:qq网络 进展:即将开始对计时技术代码的编写

  9. 多线程编程4 - GCD

    一.简介 在iOS所有实现多线程的方案中,GCD应该是最有魅力的,因为GCD本身是苹果公司为多核的并行运算提出的解决方案.GCD在工作时会自动利用更多的处理器核心,以充分利用更强大的机器.GCD是Gr ...

  10. Linux Qt动态库的创建和使用

    一.创建动态库 编写一个共享库类,比如: //..base.h class Base : public QObject { Q_OBJECT public: ); void PrintLog(QStr ...