• 纯代码-QQ登陆练习


      1 //
      2 // LWTViewController.m
      3 //  纯代码-QQ登陆
      4 //
      5 //  Created by apple on 14-5-21.
      6 //  Copyright (c) 2014年 lwt. All rights reserved.
      7 //
      8 
      9 #import "LWTViewController.h"
     10 
     11 #define KLabelX 40
     12 #define KTextFieldX 100
     13 
     14 #define KLabelWidth 40
     15 #define KTextFieldWidth 150
     16 #define kButtonWidth 60
     17 
     18 #define KHeight 25
     19 
     20 
     21 @interface LWTViewController ()
     22 
     23 // qq号码和密码属性
     24 @property (nonatomic, strong) UITextField *QQNumber;
     25 @property (nonatomic, strong) UITextField *QQPassword;
     26 
     27 
     28 @end
     29 
     30 @implementation LWTViewController
     31 
     32 - (void)viewDidLoad
     33 {
     34     [super viewDidLoad];
     35     // Do any additional setup after loading the view, typically from a nib.
     36     
     37     // 用户名
     38     [self createLable:40.0 andText:@"QQ"];
     39     // 输入框
     40     self.QQNumber = [self createTextField:40.0 andText:@"请输入QQ"];
     41     // 数字键盘
     42     self.QQNumber.keyboardType = UIKeyboardTypeNumberPad;
     43     
     44     // 密码
     45     [self createLable:80.0 andText:@"密码"];
     46     // 输入框
     47     self.QQPassword = [self createTextField:80.0 andText:@"请输入密码"];
     48     // 密码隐文
     49     self.QQPassword.secureTextEntry = YES;
     50     
     51     // 创建登陆按钮
     52     CGFloat btnX = (self.view.frame.size.width - kButtonWidth) / 2;
     53     UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(btnX, 120, kButtonWidth, KHeight)];
     54     // 设置文本
     55     [btn setTitle:@"登陆" forState:UIControlStateNormal];
     56     [btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
     57     
     58     // 设置背景颜色
     59     [btn setBackgroundColor:[UIColor whiteColor]];
     60     
     61     // 设置点击按钮事件
     62     [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
     63     
     64     [self.view addSubview:btn];
     65     
     66 }
     67 
     68 /** 创建UILabel */
     69 - (void)createLable:(CGFloat)y andText:(NSString *)text
     70 {
     71     // 创建UILabel
     72     UILabel *label = [[UILabel alloc] init];
     73     // 位置
     74     label.frame = CGRectMake( KLabelX, y, KLabelWidth, KHeight);
     75     // 文本
     76     label.text = text;
     77     // 设置居中
     78     label.textAlignment = NSTextAlignmentCenter;
     79     
     80     [self.view addSubview:label];
     81 }
     82 
     83 /** 创建UITextField */
     84 - (UITextField *)createTextField : (CGFloat)y andText:(NSString *)placeholder
     85 {
     86     // 创建UITextField
     87     UITextField *textField = [[UITextField alloc] init];
     88     // 位置
     89     textField.frame = CGRectMake(KTextFieldX, y, KTextFieldWidth, KHeight);
     90     // 边框
     91     textField.borderStyle = UITextBorderStyleRoundedRect;
     92     // 默认文本
     93     textField.placeholder = placeholder;
     94     
     95     [self.view addSubview:textField];
     96     
     97     return textField;
     98 }
     99 
    100 - (void)btnClick
    101 {
    102     NSLog(@"QQ :%@,密码 :%@", self.QQNumber.text, self.QQPassword.text);
    103     [self.view endEditing:YES];
    104 }
    105 
    106 - (void)didReceiveMemoryWarning
    107 {
    108     [super didReceiveMemoryWarning];
    109     // Dispose of any resources that can be recreated.
    110 }
    111 
    112 @end
  • 相关阅读:
    4d
    加载数据
    刘亮给的帮助
    加载数据
    选中并高亮显示
    ArcEngine
    接口编程
    好的参考文献
    在本地安装 wordpress
    C#读取EXCEL数据
  • 原文地址:https://www.cnblogs.com/wentianblog/p/3742595.html
Copyright © 2020-2023  润新知