• (纯代码)QQ登录界面:


    #import "ViewController.h"
    
    @interface ViewController ()
    
    @property (nonatomic, weak) UITextField *_textName;
    @property (nonatomic, weak) UITextField *_textPassword;
    
    @endhttp://www.cnblogs.com/pocket-mood/p/4331303.html
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        /** QQ */
        UILabel *labName = [[UILabel alloc] init];
        labName.frame = CGRectMake(15, 71, 40, 15);
        labName.text = @"QQ :";
        labName.textColor = [UIColor blueColor];
        [self.view addSubview:labName];
        
        /** 密码 */
        UILabel *labPassword = [[UILabel alloc] init];
        labPassword.frame = CGRectMake(15, 116, 40, 15);
        labPassword.text = @"密码:";
        labPassword.textColor = [UIColor redColor];
        [self.view addSubview:labPassword];
        
        /** QQ文本 */
        UITextField *textName = [[UITextField alloc] init];
        textName.frame = CGRectMake(60, 55, 260, 40);
        // 设置文本框样式(圆角矩形)
        textName.borderStyle = UITextBorderStyleRoundedRect;
        // 设置文本框在没内容时显示的占位格内容
        textName.placeholder = @"请输入QQ号";
        textName.textColor = [UIColor blackColor];
        // 设置键盘为数字键盘输入
        textName.keyboardType = UIKeyboardTypeNumberPad;
        // 设置编辑时右侧出现全部删除图标
        textName.clearButtonMode = UITextFieldViewModeWhileEditing;
        [self.view addSubview:textName];
        // 为了使_textName以后可以调用控件属性
        self._textName = textName;
        
        /** 密码文本 */
        UITextField *textPassword = [[UITextField alloc] init];
        textPassword.frame = CGRectMake(60, 100, 260, 40);
        textPassword.borderStyle = UITextBorderStyleRoundedRect;
        textPassword.placeholder = @"请输入密码";
        textPassword.textColor = [UIColor redColor];
        // 设置文本为密码状态,文本全部转化为点显示
        textPassword.secureTextEntry = YES;
        textPassword.clearButtonMode = UITextFieldViewModeWhileEditing;
        [self.view addSubview:textPassword];
        self._textPassword = textPassword;
        
        /** 登录按钮 */
        UIButton *btnRegiste = [[UIButton alloc] init];
        btnRegiste.frame = CGRectMake(15, 290, 300, 60);
        [btnRegiste setTitle:@"登录" forState:UIControlStateNormal];
        [btnRegiste setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [btnRegiste setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
        [btnRegiste setBackgroundColor:[UIColor blueColor]];
         // 设置Button按钮文本字体样式和大小
        btnRegiste.titleLabel.font = [UIFont fontWithName:@"Arial" size:28.0];
        // 监听事件的触发
        [btnRegiste addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:btnRegiste];
        
    }
    
    // 监听
    
    - (void) btnClick: (UIButton *) button
    {
        NSLog(@"----登录----
    QQ:%@
    密码:%@",self._textName.text,self._textPassword.text);
        
        // 退出键盘状态
        [self.view endEditing:YES];
    }
    
    
    
    @end
  • 相关阅读:
    在路上(转)
    我,机器
    梧桐道上
    傅盛:如何快慢“炼”金山?(转)
    [JS]笔记15之客户端存储cookie
    [JS]笔记14之事件委托
    [JS]笔记13之Date对象
    将博客搬至CSDN
    [JS]笔记12之事件机制--事件冒泡和捕获--事件监听--阻止事件传播
    [JS]笔记11之正则表达式
  • 原文地址:https://www.cnblogs.com/pocket-mood/p/4331303.html
Copyright © 2020-2023  润新知