UI UI基本控件
2014-09-29 15:52
120 查看
// // VisionAppDelegate.m // UI基本空间 // Copyright (c) 2014年 Vision. All rights reserved. // #import "VisionAppDelegate.h" @implementation VisionAppDelegate - (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(30, 30, 280, 60)]; label.backgroundColor = [UIColor redColor]; [self.window addSubview:label]; //label的属性设置 //显示的文本信息 label.text = @"显示的文本信息"; //文本颜色 label.textColor = [UIColor yellowColor]; //文本阴影颜色 label.shadowColor = [UIColor blueColor]; //文本阴影偏移量 label.shadowOffset = CGSizeMake(3, 3); //文本格式处理(对齐方式) label.textAlignment = NSTextAlignmentCenter; //当文本过长时, label显示的断行方式 label.lineBreakMode = NSLineBreakByTruncatingHead; //控制label显示的行数 label.numberOfLines = 0; //系统默认字体大小17 label.font = [UIFont systemFontOfSize:20]; // label.font = [UIFont fontWithName:[[UIFont familyNames]objectAtIndex:25] size:19]; label.tag = 10; [label release]; //UITextFied UITextField *name = [[UITextField alloc]initWithFrame:CGRectMake(30,100, 280, 30)]; //默认的占位字符串 一旦输入 自动隐藏 name.placeholder = @"请在这里输入"; //输入控制 //输入转换为黑点 name.secureTextEntry = YES; //更改键盘类型 name.keyboardType = UIKeyboardTypeASCIICapable; //外观控制 name.borderStyle = UITextBorderStyleRoundedRect; //给textField设置tag name.tag = 100; //清除按钮 name.clearButtonMode = UITextFieldViewModeWhileEditing; name.backgroundColor = [UIColor clearColor]; [self.window addSubview:name]; [name release]; //UIButton UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; button.frame = CGRectMake(30, 140, 280, 30); [button setTitle:@"千万别点击我" forState:UIControlStateNormal]; //点击的时候设置button的高亮 button.showsTouchWhenHighlighted = YES; //给按钮绑定一个方法,点击的时候 让某个特定的对象调用这个方法 //参数1:执行方法的对象 //参数2:要执行的方法(参数1的对象去执行) //参数3:按钮让绑定的对象调用方法,需要触发的事件 [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside]; button.backgroundColor = [UIColor blueColor]; [self.window addSubview:button]; [_window release]; return YES; } //给按钮点击设定方法 - (void)buttonClicked:(UIButton *)button { self.window.backgroundColor = [UIColor clearColor]; NSLog(@"被点击了"); //让键盘回收 //1.找到弹出键盘的textField(通过设置tag) UITextField *textField = (UITextField *)[self.window viewWithTag:100]; //2.回收键盘 [textField resignFirstResponder]; UILabel *label = (UILabel *)[self.window viewWithTag:10]; label.text = @"我滴天"; //UIAlertView的使用 UIAlertView *alertview = [[UIAlertView alloc]initWithTitle:@"提示" message:@"我不是告诉你不要点击了么,我就问你后悔不后悔?" delegate:self cancelButtonTitle:@"我只是手抖." otherButtonTitles:@"就要点",@"就要点",@"就要点",@"就要点",@"就要点",@"就要点"@"吓尿了", nil]; [alertview show]; [alertview release]; } - (void)dealloc { [_window release]; [super dealloc]; }
相关文章推荐
- VC MFC基本控件的使用
- 在Delphi中编写控件的基本方法
- 一个只能输入数字的C#控件源码,并且可以限定数值类型,基本满足财务开发
- ASP.NET 2.0服务器控件开发之基本概念篇
- 保存ini文件和基本控件的保存函数
- CheckBoxList控件基本用法 如何给DropDownList控件添加边框[整理]
- 开发ASP.NET Atlas服务器端Extender控件——基本概念以及预先需求
- CheckBoxList控件基本用法
- Symbian添加一个控件的基本步骤
- Windows 控件限制用户输入的基本法门(.NET 篇)
- 07_VB6基本控件
- ASP.NET中的28個基本WEB控件
- C#与VB.NET服务器端控件的基本表示方法(学习之四)
- Windows 控件限制用户输入的基本法门(.NET 篇) 选择自 FlashElf 的 Blo
- Windows 控件限制用户输入的基本法门(.NET 篇) ===========转贴
- 树控件基本应用
- ListView 控件写的基本操作
- 控件适配器开启基本控件的控件状态
- 演练:为 Web 服务器控件创建基本控件设计器
- 保存ini文件和基本控件的保存函数(序:列表和树的保存)