UI_UIITextField

//

//  AppDelegate.h

//  UI02_UITextField

//

//  Created by dllo on 15/7/30.

//  Copyright (c) 2015 Clare. All rights reserved.

//


#import <UIKit/UIKit.h>


@interface AppDelegate : UIResponder <UIApplicationDelegate, UITextFieldDelegate>


@property (strong, nonatomic) UIWindow *window;


@end


//

//  AppDelegate.m

//  UI02_UITextField

//

//  Created by dllo on 15/7/30.

//  Copyright (c) 2015 Clare. All rights reserved.

//


#import "AppDelegate.h"


@interface AppDelegate ()


@end


@implementation AppDelegate


- (void)dealloc

{

    [_window release];

    [super dealloc];

}



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

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

    // Override point for customization after application launch.

    self.window.backgroundColor = [UIColor whiteColor];

    [self.window makeKeyAndVisible];

    [_window release];

    

    UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(60, 100, 50, 60)];

    [self.window addSubview:lable];

    [lable release];

    

    UILabel *lable1 = [[UILabel alloc] initWithFrame:CGRectMake(60, 200, 50, 60)];

    [self.window addSubview:lable1];

    [lable1 release];

    

    lable.text = @"账号:";

    lable1.text = @"密码:";

    

    // 输入框

    UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(120, 100, 200, 60)];

    textField.backgroundColor = [UIColor whiteColor];

    [self.window addSubview:textField];

    [textField release];

    

    // 边框

    textField.layer.borderWidth = 5;

    textField.textAlignment = NSTextAlignmentCenter;

    

    // 圆角

    textField.layer.cornerRadius = 15;

    textField.layer.masksToBounds = YES;

    textField.layer.borderColor = [UIColor orangeColor].CGColor;

    

    //    textField.text = @"欢迎来到克兰蒙多大陆";

    //    textField.textColor = [UIColor whiteColor];

    

    // 占位文本

    textField.placeholder = @"欢迎你!精灵族的勇士!";

    textField.textColor = [UIColor blackColor];

    textField.font = [UIFont systemFontOfSize:20];

    

    // 输入密码的时候会把文本变成圆点

    // textField.secureTextEntry = YES;

    

    // 设置不同的键盘类型

    // textField.keyboardType = UIKeyboardTypeNumberPad;

    

    // 改变return的样式

    // 可以把return按钮切换成不同样式

    textField.returnKeyType = UIReturnKeySearch;

    

    textField.clearsOnBeginEditing = YES;

    

    // 清除按钮的样式

    textField.clearButtonMode = UITextFieldViewModeAlways;

    

    // 创建一个view

    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(200, 200, 200, 200)];

    view.backgroundColor = [UIColor orangeColor];

    

    // 弹出一个自定义的视图,默认是键盘

    // textField.inputView = view;

    

    // 给键盘添加一个辅助视图

    textField.inputAccessoryView = view;

    

    // textField设置代理人

    textField.delegate = self;

    // 点击return回收键盘

    

    

    UITextField *textField1 = [[UITextField alloc]initWithFrame:CGRectMake(120, 200, 200, 60)];

    textField1.backgroundColor = [UIColor whiteColor];

    [self.window addSubview:textField1];

    [textField1 release];

    

    // 边框

    textField1.layer.borderWidth = 5;

    textField1.textAlignment = NSTextAlignmentCenter;

    

    // 圆角

    textField1.layer.cornerRadius = 15;

    textField1.layer.masksToBounds = YES;

    textField1.layer.borderColor = [UIColor orangeColor].CGColor;

    

    //    textField.text = @"欢迎来到克兰蒙多大陆";

    //    textField.textColor = [UIColor whiteColor];

    

    // 占位文本

    textField1.placeholder = @"请输入密码!";

    textField1.textColor = [UIColor blackColor];

    textField1.font = [UIFont systemFontOfSize:20];

    

    

    return YES;

}


// 实现协议方法

- (BOOL)textFieldShouldReturn:(UITextField *)textField

{

    NSLog(@"测试return按钮");

    /// 实现回收键盘的关键

    [textField resignFirstResponder];

    return YES;

}


- (BOOL)textFieldShouldClear:(UITextField *)textField

{

    NSLog(@"测试清除按钮");

    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




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值