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. [Unity菜鸟] Unity Web Player 相关问题 (待完善)

    1. 发布网页版Unity自适应网页大小 发布网页版,Unity3D自适应网页大小.这个问题困扰了我很长时间,今天终于把他解决了,给大家分享一下. 这里用Uinty4.0发布网页版,我去掉了里面的标题 ...

  2. ArcGIS Runtime for Android开发教程V2.0(1)基本概念

    原文地址: ArcGIS Runtime for Android开发教程V2.0(1)基本概念 - ArcGIS_Mobile的专栏 - 博客频道 - CSDN.NET http://blog.csd ...

  3. POJ3026——Borg Maze(BFS+最小生成树)

    Borg Maze DescriptionThe Borg is an immensely powerful race of enhanced humanoids from the delta qua ...

  4. Subversion安装和使用

    Subversion(SVN)是优秀的版本控制工具,其具体的的优点和详细介绍,这里就不再多说.SVN分为客户端和服务器端,一般服务器端安装在服务器上,我们开发者用的都是客户端.TortoiseSVN是 ...

  5. 摄像头(2)调用系统拍照activity来录像

    import android.app.Activity; import android.content.Intent; import android.content.pm.PackageManager ...

  6. VPN column: PPTP(2)--PPTP协议解析

    zhu_hit原创,如需转载请注明出处.Thanks. PPTP协议大体上可以分为两部分:控制层连接和隧道,下面简要介绍两部分的功能.如果要详细了解PPTP协议请阅读RFC文档. 一. Control ...

  7. 【转】如何在Ubuntu11.10(32位)下编译Android4.0源码(图文)

    原文网址:http://blog.csdn.net/flydream0/article/details/7046612 关于如何下载Android4.0的源码请参考我的另一篇文章: http://bl ...

  8. xmlns 属性

    xmlns 属性 xmlns 属性可以在文档中定义一个或多个可供选择的命名空间.该属性可以放置在文档内任何元素的开始标签中.该属性的值类似于 URL,它定义了一个命名空间,浏览器会将此命名空间用于该属 ...

  9. Ofbiz 10.04 + eclipse 安装与配置

    1.下载 ofbiz 10.04:http://ofbiz.apache.org/download.html: 2.下载 freemarker-2.3.15 eclipse 插件(FreeMarker ...

  10. jquery的全选/全不选/反选以及attr添加checked属性失败的解决办法

    如下图: <head> <title></title> <style type="text/css"> div { border: ...