UI UI基本控件

//
//  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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值