#import "AppDelegate.h"
@implementation AppDelegate
- (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];
// UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 280, 50)];
// // 在label上显示文字
// label.text = @"阿道夫就得 xx0";
// // 改变颜色
// [label setTextColor:[UIColor yellowColor]];
// // 文本的对齐方式
// label.textAlignment = NSTextAlignmentCenter;
// //文本的省略方式(如果文本过长)
// label.lineBreakMode = NSLineBreakByTruncatingMiddle;
// // 文本的字体大小
// label.font = [UIFont systemFontOfSize:30];
//
//
// // 文本的阴影
// label.shadowColor = [UIColor greenColor];
// label.shadowOffset = CGSizeMake(15, 15);
//
// [label setBackgroundColor:[UIColor yellowColor]];
// [self.window addSubview:label];
// [label release];
//
// UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 150, 280, 50)];
// label1.text = @"爽水电费要";
// [label1 setTextColor:[UIColor yellowColor]];
// label1.textAlignment = NSLineBreakByTruncatingMiddle;
// [label1 setBackgroundColor:[UIColor orangeColor]];
// [self.window addSubview:label1];
// [label1 release];
// 单行文本输入控件
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 20, 280, 50)];
textField.text = @“阿萨德飞一发么";
//用户提示信息
textField.placeholder = @"真的要来么";
textField.backgroundColor = [UIColor greenColor];
textField.clearsOnBeginEditing = YES;// 开始编辑的时候清空文本
textField.secureTextEntry = NO; // 输出 密码类型黑点
//输入框的边框
textField.borderStyle = UITextBorderStyleRoundedRect;
// 键盘样式
[textField setKeyboardType:UIKeyboardTypeNumberPad];
[self.window addSubview:textField];
[textField release];
// UIButton 创建
//学习新的类 1. 看类的继承关系 2.看是否有自己的初始化方式
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
// button设置标题 (在正常状态下)
[button setTitle:@"来一发" forState:UIControlStateNormal];
// 修改 button 字体大小
button.titleLabel.font = [UIFont systemFontOfSize:25];
[button setBackgroundColor:[UIColor cyanColor]];
[button setFrame:CGRectMake(18, 200, 280, 50)];
// 给button添加一个响应事件(方法)
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.window addSubview:button];
// 对应 alloc
[self.window release];
return YES;
}
- (void)dealloc
{
//属性的内存管理
[_window release];
[super dealloc];
}
//button的响应方法
- (void)buttonClicked:(UIButton *)button
{
// 只能点一次
button.enabled = NO;
NSLog(@"你好好看见客户");
}
- (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