#import "AppDelegate.h"app
@interface AppDelegate ()less
@end ide
@implementation AppDelegate字体
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {ui
// Override point for customization after application launch.this
_window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];spa
[_window setBackgroundColor:[UIColor whiteColor]];.net
//=====================================3d
//UITextField:UIControl:UIViewrest
//1.建立一个UITextField对象
UITextField *textField = [[UITextField alloc ]initWithFrame:
CGRectMake(100, 100, 200, 50)];
//2.添加到界面上
[_window addSubview:textField];
//3.设置背景色
[textField setBackgroundColor:[UIColor yellowColor]];
//=============textField和文字相关属性================
//1.text(能够经过这个属性改变textField显示的文字
//更多的时候是经过这个属性去拿到里面的textField的text值)
textField.text = @"hello luhan";
//2.文字颜色
textField.textColor = [UIColor redColor];
//3.设置字体
textField.font = [UIFont systemFontOfSize:17];
//4.设置居中模式
textField.textAlignment = NSTextAlignmentLeft;
//5.占位文字(浅灰文字不能够改变);(提示文字)
//只有textField里面没有文字才会显示占位文字;
//textField.text = nil;
[textField setPlaceholder:@"请输入名字"];
//6.是否在开始编辑的时候清空文字(默认是NO);
[textField setClearsOnBeginEditing:YES];
//7.
//=================textField和显示相关的属性==================
// UITextBorderStyleNone,(默认是没有边框的)
// UITextBorderStyleLine,
// UITextBorderStyleBezel,
// UITextBorderStyleRoundedRect
//1.设置边框风格
[textField setBorderStyle:UITextBorderStyleRoundedRect];
//2.设置清除按钮模式
// UITextFieldViewModeNever,默认一致都不显示
// UITextFieldViewModeWhileEditing,编辑的时候显示
// UITextFieldViewModeUnlessEditing,除了编辑的时候都要显示
// UITextFieldViewModeAlways一致显示
[textField setClearButtonMode:UITextFieldViewModeWhileEditing];
//3.设置textField的左视图(能够传任意继承子UIView的视图对象)
//设置左视图坐标是没有意义的.
UILabel *leftLabel = [[UILabel alloc]initWithFrame:
CGRectMake(0, 0, 50, 50)];
leftLabel.text = @"帐号:";
leftLabel.textColor = [UIColor grayColor];
textField.leftView = leftLabel;
//4.设置左视图模式(默认是一直不显示)
// UITextFieldViewModeNever,默认一致都不显示
// UITextFieldViewModeWhileEditing,编辑的时候显示
// UITextFieldViewModeUnlessEditing,除了编辑的时候都要显示
// UITextFieldViewModeAlways一致显示
[textField setLeftViewMode:UITextFieldViewModeAlways];
//5.设置自定制的键盘;(只有设置高度是有效的)
UIView *inputView = [[UIView alloc]initWithFrame:
CGRectMake(0, 0,0,20)];
inputView.backgroundColor = [UIColor yellowColor];
[textField setInputAccessoryView:inputView];
//6.设置二级键盘
UIView *accessoryView = [[UIView alloc]initWithFrame:
CGRectMake(0, 0, 0, 10)];
accessoryView.backgroundColor = [UIColor redColor];
[textField setInputAccessoryView:accessoryView];
//==================textField和编辑相关的属性===========================
//判读当前textField是否处于编辑状态
//编辑状态:
BOOL ret = textField.isEditing;
NSLog(@"是否处于编辑状态:%@",ret?@"是在编辑":@"没有编辑");
[_window makeKeyAndVisible];
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