UI UI基本控件

来源:互联网 发布:nginx 图片加载不出来 编辑:程序博客网 时间:2024/05/03 22:19
////  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];}

0 0
原创粉丝点击