A.storyboard 控件版
1.label
2.textfield
     a.Keyboard Type
          账号:Number Pad
          密码:Number and Punctuation
     b.Placeholder:提示文字
     c.Clear Button: Appears with editing 清除按钮
     d.Secure Text Entry:密码格式输入
3.button
 1 @interface ViewController ()
2 @property (weak, nonatomic) IBOutlet UITextField *qqField;
3 @property (weak, nonatomic) IBOutlet UITextField *pwdField;
4
5 - (IBAction)login;
6
7 @end
8
9 @implementation ViewController
10
11 - (void)viewDidLoad {
12 [super viewDidLoad];
13 // Do any additional setup after loading the view, typically from a nib.
14 }
15
16 - (void)didReceiveMemoryWarning {
17 [super didReceiveMemoryWarning];
18 // Dispose of any resources that can be recreated.
19 }
20
21 - (IBAction)login {
22 NSLog(@"%@ - %@", self.qqField.text, self.pwdField.text);
23 }
24 @end
 
B.通过代码创建按钮
 1 @interface ViewController ()
2
3 - (void) addLabel;
4 - (void) addTextField;
5 - (void) addLoginButton;
6 - (void) login;
7
8 @end
9
10 @implementation ViewController
11
12 - (void)viewDidLoad {
13 [super viewDidLoad];
14 // Do any additional setup after loading the view, typically from a nib.
15
16 [self addLabel];
17 [self addTextField];
18 [self addLoginButton];
19 }
20
21 - (void)didReceiveMemoryWarning {
22 [super didReceiveMemoryWarning];
23 // Dispose of any resources that can be recreated.
24 }
25
26 - (void) addLabel {
27 UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 45, self.view.frame.size.width, 21)];
28 [titleLabel setTextAlignment:NSTextAlignmentCenter];
29 titleLabel.text = @"QQ登陆界面2";
30 [self.view addSubview:titleLabel];
31
32 UILabel *qqLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 91, 26, 21)];
33 qqLabel.text = @"QQ";
34 [self.view addSubview:qqLabel];
35
36 UILabel *pwdLabel = [[UILabel alloc] initWithFrame:CGRectMake(60, 131, 34, 21)];
37 pwdLabel.text = @"密码";
38 [self.view addSubview:pwdLabel];
39 }
40
41 - (void) addTextField {
42 UITextField *qqField = [[UITextField alloc] initWithFrame:CGRectMake(109, 87, 151, 30)];
43 qqField.placeholder = @"请输入QQ账号";
44 [qqField setClearButtonMode:UITextFieldViewModeWhileEditing];
45 [qqField setKeyboardType:UIKeyboardTypeNumberPad];
46 [qqField setBorderStyle:UITextBorderStyleRoundedRect];
47 [qqField setTag:1];
48 [self.view addSubview:qqField];
49
50 UITextField *pwdField = [[UITextField alloc] initWithFrame:CGRectMake(109, 127, 151, 30)];
51 pwdField.placeholder = @"请输入QQ密码";
52 [pwdField setSecureTextEntry:YES];
53 [pwdField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
54 [pwdField setClearButtonMode:UITextFieldViewModeWhileEditing];
55 [pwdField setBorderStyle:UITextBorderStyleRoundedRect];
56 [pwdField setTag:2];
57 [self.view addSubview:pwdField];
58 }
59
60 - (void) addLoginButton {
61 // 注意如果使用UIButtonTypeCustom,默认背景色和titleColor都是是白色,显示不出来
62 UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
63
64 CGRect loginRect = CGRectMake(145, 177, 30, 30);
65 loginButton.frame = loginRect;
66 [loginButton setTitle:@"登陆" forState:UIControlStateNormal];
67 [loginButton addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchUpInside];
68
69 [self.view addSubview:loginButton];
70 }
71
72 #pragma mark - action
73 - (void) login {
74 UITextField *qqField = [self.view viewWithTag:1];
75 UITextField *pwdField = [self.view viewWithTag:2];
76
77 NSLog(@"登陆---->%@ - %@", qqField.text, pwdField.text);
78 }
79 @end
 
 

[iOS基础控件 - 3.1] QQ登陆界面的更多相关文章

  1. [iOS基础控件 - 6.9.1] 聊天界面Demo 代码

    框架:   所有代码文件:   Model: // // Message.h // QQChatDemo // // Created by hellovoidworld on 14/12/8. // ...

  2. [iOS基础控件 - 5.5] 代理设计模式 (基于”APP列表"练习)

    A.概述      在"[iOS基础控件 - 4.4] APP列表 进一步封装,初见MVC模式”上进一步改进,给“下载”按钮加上效果.功能      1.按钮点击后,显示为“已下载”,并且不 ...

  3. [iOS基础控件 - 6.12.1] QQ菜单管理 UITabBarController 控制器管理

    A.需求 1.类似QQ.微信顶部或者底部的窗口转换导航条 2.给每个页面添加相应内容   B.UITabBarController 1.基本概念: (1)内容高度 iOS7之前内容高度为:屏幕高度 - ...

  4. [iOS基础控件 - 6.9.3] QQ好友列表Demo TableView

    A.需求 1.使用plist数据,展示类似QQ好友列表的分组.组内成员显示缩进功能 2.组名使用Header,展示箭头图标.组名.组内人数和上线人数 3.点击组名,伸展.缩回好友组   code so ...

  5. iOS 基础控件(下)

    上篇介绍了UIButton.UILabel.UIImageView和UITextField,这篇就简短一点介绍UIScrollView和UIAlertView. UIScrollView 顾名思义也知 ...

  6. [iOS基础控件 - 6.11.3] 私人通讯录Demo 控制器的数据传递、存储

    A.需求 1.搭建一个"私人通讯录"Demo 2.模拟登陆界面 账号 密码 记住密码开关 自动登陆开关 登陆按钮 3.退出注销 4.增删改查 5.恢复数据(取消修改)   这个代码 ...

  7. [iOS基础控件 - 6.9] 聊天界面Demo

    A.需求 做出一个类似于QQ.微信的聊天界面 1.每个cell包含发送时间.发送人(头像).发送信息 2.使用对方头像放在左边,我方头像在右边 3.对方信息使用白色背景对话框,我方信息使用蓝色背景对话 ...

  8. [iOS基础控件 - 7.0] UIWebView

    A.基本使用 1.概念 iOS内置的浏览器控件 Safari浏览器就是通过UIWebView实现的   2.用途:制作简易浏览器 (1)基本请求 创建请求 加载请求 (2)代理监听webView加载, ...

  9. [iOS基础控件 - 6.10.2] PickerView 自定义row内容 国家选择Demo

    A.需求 1.自定义一个UIView和xib,包含国家名和国旗显示 2.学习row的重用   B.实现步骤 1.准备plist文件和国旗图片     2.创建模型 // // Flag.h // Co ...

随机推荐

  1. easyui源码翻译1.32+API翻译全篇导航 (提供下载源码)

    前言 EasyUI每个组件都会有 属性.方法.事件 属性 所有的属性都定义在jQuery.fn.{plugin}.defaults里面.例如,对话框属性定义在jQuery.fn.dialog.defa ...

  2. Sequel Pro 免费的MySQL管理客戶端(有SSH部分)

    官方站點:http://www.sequelpro.com Sequel Pro 的原名是 CocoaMySQL,是一个与 phpMyAdmin 類似的 MySQL 管理工具.它是由 Cocoa 和面 ...

  3. request对象常用API 获取请求参数的值 request应用 MVC设计模式

    1 request对象常用API   1)表示web浏览器向web服务端的请求   2)url表示访问web应用的完整路径:http://localhost:8080/day06/Demo1     ...

  4. 【开源推荐】AllJoyn:打造全球物联网的通用开源框架

    摘要:随着智能设备的发展,物联网逐渐进入了人们的生活.据预测,未来几乎一切东西(超过500亿台设备)都可以互联.高通公司发布了开源项目AllJoyn,这是一个能够使连接设备间进行互操作的通用软件框架和 ...

  5. 转载:C++ vector 类学习笔记

    声明:本文转载自http://blog.csdn.net/whz_zb/article/details/6827999 vector简介 vector是STL中最常见的容器,它是一种顺序容器,支持随机 ...

  6. windows10 无法搜索本地应用的解决办法

    博客好久没有更新了,今天拔下草,不多说,直接说如何解决吧.目前看到的比较靠谱的解决方案有4种,应该能解决绝大部分人的问题. 方法1和方法2 百度经验里面说的很清楚了,这里不再多说,大家可以直接参考:链 ...

  7. 函数flst_add_last

    /********************************************************************//** Adds a node as the last no ...

  8. bzoj1025: [SCOI2009] 游戏 6

    DP. 每种排法的长度对应所有循环节长度的最小公倍数. 所以排法总数为和为n的几个数的最小公倍数的总数. #include<cstdio> #include<algorithm> ...

  9. Java [leetcode 30]Substring with Concatenation of All Words

    题目描述: You are given a string, s, and a list of words, words, that are all of the same length. Find a ...

  10. Windows 之间用rsync同步数据(cwRsyncServer配置)

    rsync是一款优秀的数据同步软件,在跨服务器,跨机房,跨国备份服务器的首选工具,下面就来介绍下如何配置安装cwRsyncServer很大多数软件一样是B/C架构,cwRsyncServer是rsyn ...