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

news/2023/12/8 18:45:45
Image
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


http://www.ppmy.cn/news/854163.html

相关文章

让iphone可装android双启动,只需几步 iPhone可装Android双启动

苹果的iOS以其封闭性而著称,相比Android这种开放性系统,iOS很难移植到其他设备上,不过Android就已经成功的入侵到iPhone手机之中。使用iPhoDroid工具就可以很容易的将iPhone变成一部iOS和Android双系统启动设备,近日这款工具再次进…

ios 只用3x图可以吗_对于仅限iPhone的iOS 7应用,我们只能包含@ 3x图像吗?

是的,你可以,但你不应该。 如果您只添加 3x图像,它将减少您的捆绑包大小,并与所有屏幕密度兼容。 不过,我不建议这样做。仅嵌入 3x图像将导致您的图像在每次运行应用程序时缩小。这种方法有以下缺点: >您…

如何在代码中判断当前设备是iPhone 4/4S还是iPhone 5?

( NSString *)deviceString { // 需要#import "sys/utsname.h" struct utsname systemInfo; uname(&systemInfo); NSString *deviceString [ NSString stringWithCString:systemInfo.machine encoding: NSUTF8StringEncoding ]; if ([deviceString isEqualT…

transform: translate在IOS下失效

样式如下 .ant-progress {margin-top: 30px;position: relative;left: 50%;transform: translateX(-50%);}在安卓中,效果如下 在IOS中,效果如下 解决办法: 网上找不到比较好的方法,所有选择曲线救国,在外面套个Div&a…

请求库之 selenium模块

介绍:selenium最初是一个测试工具,而爬虫中使用它主要是为了解决requests无法直接执行JavaScript代码的问题 selenium本质是通过驱动浏览器,完全模拟浏览器的操作,比如跳转、输入、点击、下拉等,来拿到网页渲染之后的结果&#xf…

ios 只用3x图可以吗_iOS 图片 @2x与@3x区别

一部好看的电影《看不见的客人》,老年人被逼无奈的情况下,激发了他们的最大潜能,逼凶手认罪伏法。有些时候,人都是被逼的... 28号面试了一位同僚,想起了之前腾讯电话面试我的一个问题,2x和3x的图片有啥区别&#xff0c…

根据iphone3/ios5开发基础教程-录制ios视频基础教程-视频下载专辑/反馈

根据iphone3/ios5开发基础教程-录制ios视频基础教程-视频下载专辑/反馈 原文地址:http://www.lwxshow.com/forum-2-1.html 大家觉得有必要下载高清版本的回帖我统计下,方便大家使用本地的播放器查看。 IOS5.1,Xcode4.3.2iphone/ipad开发视频基础教程 以下是ios视频基…

从 iphone3开发基础教程 开始 (1)

家里实际上有四本学习ios的书籍, 唯独这本书被weiphone网所推荐. 因此自己的ios学习将从这本书开始. 虽然ios版本即将升级到4.3, 是不是学习3.0版本的ios有些过时呢?不是的, 虽然ios的版本在不断提高, 但其核心还是基于object c语言, 其编程环境还是xcode, 还是相同的编程方式…

从iphone3到iphone4的程序界面。

sdk4里提出一个point的概念,来代替pixel。 使得使用point来设计的标准界面能平滑的从iphone3上移动到iphone4上。 这种“投机取巧”的设计能真是开发者的福音,只要按照iphone3的整数倍率放大的屏幕,都可以无事运行。 但是也不是完全的万事…

关于Iphone3和Iphone4按键Home失效

有不少人买了Iphone3、4 手机很贵,而且iphone3的Home很容易坏,一旦坏了,修的话不少费用,但不修,基本报废。下面我来讲解怎么来安装一款软件来代替Home,不管你的手机是好是坏,安装不影响。 1.首先…

iPhone5分辨率兼容(iPhone3,4,4S)

配置最显眼的外观变化要数屏幕,由之前的3.5英寸升级至4.0英寸,分辨率为1136 * 640像素,326ppi。屏幕上现在可以放置5排图标。 iPhone 5厚度为7.6mm,重量为112g,比4S薄了18%、轻了20%。外壳采用全铝材质以及高强度玻璃&…

iPhone3开发基础教程中部分有用代码片段(1)

《beginning iphone3 development exploring the iphone SDK》一书中有很多基础的代码片段 ,由这些最原始的代码片段组成了我们的复杂的iphone应用程序,所以这里就借用一网友的总结,一大家一起分享。 1. stringWithFormat 用法: v…

iphone3开发基础教程

学习ios 要两本书 1.Objective-C基础教程 下载地址 : http://www.kuaipan.cn/file/id_28743136620607856.htm 2.iphone3开发基础教程 下载地址 : http://www.kuaipan.cn/file/id_28743136620607821.htm http://www.kuaipan.cn/file/id_2874313662060…

iphone3开发基础教程中文版高清PDF全集迅雷高速下载

转自: http://bbs.lwxshow.com/thread-127-1-1.html 资源-IOS开发:Iphone3开发基础教程中文版高清PDF迅雷高速下载 Iphone3开发基础教程PDF下载 高速下载

Begin iPhone3 development

开始翻翻这本书,看看基础了又... 话说csdn的博客现在越来越不好用了,我勤快点,弄个自己的博客吧,否则真折腾不起... 1. 源码和pdf 话说我居然在官网上没有找到下载连接,切 http://www.cocoachina.com/iphonedev/sdk/…

iphone3开发基础教程pdf

下载地址:网盘下载 内容简介 Apple公司的iPhone已经开创了移动平台新纪元!而最新版iPhone 3做了不少改进,如强化应用程序对GPS的支持,增加了众多新功能,如全系统搜索、支持复制和粘贴、收发多媒体信息等。iPhon…

上门维修APP软件开发|上门维修预约小程序开发

上门维修软件开发适合多个行业,特别是那些需要提供上门服务的行业。下面将介绍几个适合开发上门维修软件的行业。   家电维修行业:家电维修是一个常见的需求,包括电视、空调、冰箱、洗衣机等家电设备。开发上门维修软件可以方便用户在线预约…

如何把google日历添加到桌面

如何把google日历添加到桌面吧

带有日历提醒的软件,电脑桌面便签可设定日历提醒

放在电脑桌面上使用的便签软件,工作族能找到很多,电脑便签软件以其小小的界面悬挂在电脑桌面深受大家的喜欢,一来不影响正常办公,二来悬挂的小窗口可以实时起到提醒大家的作用。 比较好用的桌面便签软件一定要带有日历提醒的功能…

怎样把日常要做的事情记录和显示在桌面便签日历上

现在的上班族每天都很忙啊,每天都有那么多的事情要处理,怎么在日历上记住这些事呢?在纸质日历上记事,是很古老的记事方法。用电脑的人在日历上记事,用的都是桌面日历便签,在日历便签上记事,会更…
最新文章