zoukankan      html  css  js  c++  java
  • 登陆页面

    //

    //  AppDelegate.m

    //  UI_Lesson2 login

    //

    //  Created by 李洪鹏 on 15/6/30.

    //  Copyright (c) 2015年 李洪鹏. All rights reserved.

    //

    #import "AppDelegate.h"

    @interface AppDelegate ()

    @property (nonatomic, retain)UIView *view;

    @end

    @implementation AppDelegate

    -(void)dealloc

    {

        [_window release];

        [_view release];

        [super dealloc];

    }

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

        // Override point for customization after application launch.

        

        self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

        self.window.backgroundColor = [UIColor whiteColor];

        [self.window makeKeyAndVisible];

        

        UILabel *useName = [[[UILabel alloc]initWithFrame:CGRectMake(30, 50, 80, 40)] autorelease];

        useName.text = @"用户名";

        [self.window addSubview:useName];

        

        

        UITextField *useNametextField = [[[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(useName.frame) + 20, CGRectGetMinY(useName.frame), 160, 40)] autorelease];

        useNametextField.placeholder = @"请输入用户名";

        useNametextField.borderStyle = UITextBorderStyleRoundedRect;

        [self.window addSubview:useNametextField];

        

        

        UILabel *Pwd = [[[UILabel alloc]initWithFrame:CGRectMake(30, 100, 80, 40)]autorelease];

        

        Pwd.text = @"密码";

        [self.window addSubview:Pwd];

        

        

        UITextField *pwdTextField = [[[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(Pwd.frame) + 20, CGRectGetMidY(Pwd.frame), 160, 40)] autorelease];

        pwdTextField.placeholder = @"请输入密码";

        pwdTextField.borderStyle = UITextBorderStyleRoundedRect;

        pwdTextField.secureTextEntry = YES;

        [self.window addSubview:pwdTextField];

        

        

        //设置代理

        useNametextField.delegate = self;

        pwdTextField.delegate = self;

        

        //登陆按钮

        UIButton *button1 = [UIButton buttonWithType:UIButtonTypeSystem];

        button1.backgroundColor = [UIColor greenColor];

        

        button1.frame = CGRectMake(CGRectGetMinX(Pwd.frame) + 20, CGRectGetMaxY(Pwd.frame) + 30, 60, 40);

        [button1 setTitle:@"登陆" forState:UIControlStateNormal];

        [button1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

        

        //找回密码

        UIButton *button2 = [UIButton buttonWithType:UIButtonTypeSystem];

        button2.backgroundColor = [UIColor greenColor];

        

        button2.frame = CGRectMake(CGRectGetMaxX(button1.frame) + 20, CGRectGetMidY(button1.frame) - 20, 60, 40);

        

        [button2 setTitle:@"找回密码" forState:UIControlStateNormal];

        [button2 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

        [self.window addSubview:button2];

        

        //注册button

        

        UIButton *button3 = [UIButton buttonWithType:UIButtonTypeSystem];

        button3.backgroundColor = [UIColor greenColor];

        button3.frame = CGRectMake(CGRectGetMaxX(button2.frame) + 20 , CGRectGetMidY(button1.frame) - 20, 60, 40);

        

        [button3 setTitle:@"注册" forState:UIControlStateNormal];

        [button3 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

        [self.window addSubview:button3];

        

    //    [button setTitle:@"我怕" forState:UIControlStateHighlighted];

    //    [button setTitleColor:[UIColor orangeColor] forState:UIControlStateHighlighted];

    //    UIButton *buttron

        

        

        

    //    设置背景图片

    //    [button setBackgroundImage:[UIImage imageNamed:@"许李超.jpeg"] forState:UIControlStateNormal];

    //    

    //    [button setBackgroundImage:[UIImage imageNamed:@"杨福堂.jpg"] forState:UIControlStateHighlighted];

        

    //    [button setImage:[UIImage imageNamed:@"许李超.jpeg"] forState:UIControlStateNormal];

    //    [button setImage:[UIImage imageNamed:@"杨福堂.jpg"] forState:UIControlStateHighlighted];

        

        [self.window addSubview:button1];

        

        #pragma mark - 给button绑定点击事件

        [button1 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];

        

        //view.tag = 101;

        

        [self.window addSubview:self.view];

        

        //注册按钮

        //UIButton *button1 = [UIButton buttonWithType:UIButtonTypeSystem];

        

        return YES;

    }

    - (void)buttonAction:(UIButton *)sender

    {

    //    int red = arc4random() % (255 - 0 + 1) + 0;

    //    int green = arc4random() % (255 - 0 + 1) + 0;

    //    int blue = arc4random() % (255 - 0 + 1) + 0;

    //    

    //    //UIView *view = [self.window viewWithTag:101];

    //    

    //    self.view.backgroundColor =  [UIColor colorWithRed:red / 255.0 green:green / 255.0 blue:blue / 255.0 alpha:1.0f];

        

        UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"点我啊,点我啊s" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",@"测试", nil];

        [alertView show];

        [alertView release];

        

    }

    //点击了 alertview 的取消 或者确定 的方法

    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

    {

        if (buttonIndex == 0) {

            NSLog(@"点击了取消");

        }else if (buttonIndex == 1) {

            NSLog(@"点击了确定");

        }else{

            NSLog(@"点击了测试");

        }

        

    }

    - (BOOL)textFieldShouldReturn:(UITextField *)textField

    {

        [textField resignFirstResponder];

        return YES;

    }

    - (void)applicationWillResignActive:(UIApplication *)application {

        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

        // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

    }

    - (void)applicationDidEnterBackground:(UIApplication *)application {

        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.

        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

    }

    - (void)applicationWillEnterForeground:(UIApplication *)application {

        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.

    }

    - (void)applicationDidBecomeActive:(UIApplication *)application {

        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

    }

    - (void)applicationWillTerminate:(UIApplication *)application {

        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

    }

    @end

  • 相关阅读:
    构造函数与析构函数2
    构造函数与析构函数(其中有两点值得学习)
    构造函数含有含默认值的参数
    A simple stack
    指针与const
    构造函数与析构函数
    构造函数的创建
    类的定义
    程序的堆与栈(转载)
    OpenStack 安装:glance 安装
  • 原文地址:https://www.cnblogs.com/lhp-1992/p/4611397.html
Copyright © 2011-2022 走看看