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

转载于:https://www.cnblogs.com/hellovoidworld/p/4119704.html

[iOS基础控件 - 3.1] QQ登陆界面相关推荐

  1. [iOS基础控件 - 6.7] 微博展示 使用代码自定义TableCell(动态尺寸)

    A.需求 1.类似于微博内容的展示 2.头像 3.名字 4.会员标志 5.内容 6.分割线 7.配图(可选,可有可无) code source: https://github.com/hellovoi ...

  2. [iOS基础控件 - 6.9.4] 抓取网页图片资源

    A.需求 1.利用浏览器取得网页的源码 2.解析源码,获取图片地址(这里使用了java的一个库来解析html) 3.获取资源,生成plist目录 B.实现步骤 1.打开一个网页,最好里面是包含了静态布 ...

  3. [iOS基础控件 - 6.2] LOL英雄列表 UITableView单项显示

    A.需求 1.使用只有一个section的TableView来显示LOL 的英雄列表 2.内容包括标题.副标题.图标 3.使用plain样式 4.使用MVC模式 heros.plist 文件结构: 这 ...

  4. [iOS基础控件 - 5.3] 电台APP可滚动主界面(UIScrollView制作)

    A.功能 1.上下可滚动的电台 2 x n 的图标集 2.顶部半透明标题 3.底部半透明功能按钮 B.实现思路 1.设置图标.启动画面 2.拖入UIScrollView,设置背景色 (1)设置cont ...

  5. iOS基础控件-UITabBarController - 3 之UITabBarControllerDelegate协议中的四个重要方法

    让AppDelegate遵守UITabBarControllerDelegate 协议 在 XSAppDelegate.m 中的 - (BOOL)application:( UIApplication ...

  6. iOS界面设计之基础控件的学习 --- UITextField

    学习iOS界面设计也有段时间了,每次写到一些基础控件(如:UILable . UITextField)的时候就深觉应该总结一个函数来实现这些基础控件的属性设置,所以下面就是我对UITextField的 ...

  7. iOS小白之路...iOS中基础控件的使用

    UIlabel是iOS开发中应用比较广泛的一个基础控件. uilabel最重要的功能是为我们提供文本展示. uilabel有哪些常用的属性. >uilabel.text设置文本标签展示文字 &g ...

  8. android布局基础及范例:QQ登陆界面设计

    使用android手机的用户想必都有android手机QQ客户端吧,我们是不是觉得QQ登陆界面非常漂亮美观而且具有亲和力?我们是不是也想作出像 QQ那样美观的界面?有的人肯定会问,做UI那不是美工人员 ...

  9. Unity3d UGUI基础控件使用(一)

    转载自:Unity3d UGUI基础控件使用(一) 一:UGUI介绍 UGUI是Unity4.6之后,经过多重测试,推出全新的UI系统,更灵活,快捷,易用的可视化游戏UI开发工具. 由于之前传统的UI ...

最新文章

  1. RT-Thread与智能车比赛
  2. (总结1)HTML5中新增加的表单元素
  3. 为什么使用HashMap需要重写hashcode和equals方法_为什么要重写 hashcode 和 equals 方法?...
  4. 联机装箱问题 java_Java实现 洛谷 P1049 装箱问题
  5. vivado烧写FPGA速度调节
  6. hbase/thrift/go连接失败
  7. hibernate数据库连接池
  8. 指针变量的声明、地址相关运算--“*”和“”
  9. c语言程序设计 实验十一,C语言实验十一 结构体程序设计(二)
  10. 用python计算准确率_Pytorch 计算误判率,计算准确率,计算召回率的例子
  11. oracle设置口令期限,[20180316]改变oracle用户口令时限.txt
  12. 2019美赛参赛获奖经验
  13. PCHunter_32X64_2022_03最新版
  14. 2017.3.5阿凡python简单爬虫尝试,奉献源码
  15. TMS320F28335 - eCAP、eQEP
  16. 机器人路径规划_人工蜂群算法
  17. 如何做好Clickhouse集群的监控覆盖?
  18. IO流(输入流与输出流)
  19. 活在IT,半路捡起硌脚的石子
  20. linux can总线接收数据串口打包上传_使用Zedboard开发板学习Linux的移植及驱动开发...

热门文章

  1. MySQL 2059报错
  2. 华南理工计算机学院硕士研究生导师何生导师,中国南玻集团何进副总裁获聘华南理工大学研究生校外导师...
  3. 数据结构与算法学习笔记之先进先出的队列
  4. 英雄联盟服务器维护3月17,lol3月17日停机维护多久 英雄联盟今天停机维护持续多长时间...
  5. 手机摄像头不可思议的3个功能,普通人一定不知道!
  6. python soup attrs_python Beautiful Soup常用过滤方法
  7. snipaste——一款强大的、免费的截图软件
  8. 【Espruino】NO.15 nRF24L01+无线收发器
  9. 大数据——HBase数据库操作实例
  10. ApplicationListener