注意:AppDelegate是类,所以self在这个类中指的就是AppDelegate对象

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

   
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease];

   

   
UIView
*contentView =
[[UIView
alloc]initWithFrame:[UIScreen
mainScreen].bounds];

   
contentView.backgroundColor = [UIColor brownColor];

   
[self.window
addSubview:contentView];
===========================================================
#pragma mark
----------UILabel知识点------------
  
1、 //UILabel (标签)
,UIView的子类,在UIView的基础上扩充了实现文字的功能




    
1.创建控件

    
2.配置属性

    
3.添加到父视图上

    
4.释放所有权release

   
//1.创建UILabel对象
   
UILabel
*label =
[[UILabel
alloc]initWithFrame:CGRectMake(10,
30, 300, 60)];

   
//2.配置UILabel的属性

   
//2.1
配置背景颜色

   
[label setBackgroundColor:[UIColor
cyanColor]];

   
//2.2
设置显示的文字

   
label.text = @"欢迎进入QQ登录界面";

   
//2.3
设置文字的颜色

   
label.textColor = [UIColor redColor];

   
//2.4
设置文本居中

   
label.textAlignment = NSTextAlignmentCenter;

//2.5
设置文字大小

   
label.font = [UIFont systemFontOfSize:30];

   
//字体采用加粗的字体样式

label.font = [UIFont boldSystemFontOfSize:25];

//UIFont是一个字体

   
//遍历系统中可以使用字体名称
 
  for (NSString *name in [UIFont familyNames])
{
 
     
NSLog(@"%@",name);
  
}
 
  label.font = [UIFont fontWithName:@"Marion"
size:25];

//2.6
设置文本的行数

   
label.numberOfLines = 0;//设置为0,表示不限制行数,默认为1行

//2.7
行数的截取方式

   
//NSLineBreakByWordWrapping = 0,
   
   
//NSLineBreakByClipping,
   
//NSLineBreakByTruncatingHead,
   
//NSLineBreakByTruncatingTail
   
//NSLineBreakByTruncatingMiddle
   
//常用为以下两个

   
//NSLineBreakByWordWrapping通过单词截取
   
//NSLineBreakByCharWrapping 通过字符截取
   
label.lineBreakMode = NSLineBreakByWordWrapping;

//2.8
设置阴影颜色

   
label.shadowColor = [UIColor blackColor];

   
//2.9
阴影的偏移量
   
label.shadowOffset = CGSizeMake(1, 2);

   
//2.10
设置文本的对齐方式

   
label.textAlignment = NSTextAlignmentCenter;

//NSTextAlignmentLeft
     
左对齐

   
//NSTextAlignmentRight   
右对齐

   
//NSTextAlignmentCenter 
居中对齐

 
   //2.11
切圆角,下面两个同时才能显示
    label.layer.cornerRadius

=
10;//切圆角

   
label.layer.masksToBounds
=
YES;
   
//3.添加到父视图

[contentView addSubview:label];

   
//4.释放所有权

   
[label release];

   

#pragma mark
----------UITextField知识点------------

2、  
 UITextField   继承自UIControl
,是在UILabel的基础上扩充了文本编辑的功能,可以允许用户用户输入或者修改文字





 
  
//1.创建UITextField
对象

   
UITextField
*textField =
[[UITextField alloc]initWithFrame:CGRectMake(80, 200, 200, 30)];

   
//2.配置属性

   
//shift + command +k
收回和放出键盘

   
textField.backgroundColor = [UIColor whiteColor];

   
//文本框类型

   
textField.borderStyle = UITextBorderStyleRoundedRect;

//2.2
设置文本框的提示文字

   
textField.placeholder = @"请输入账号";

   
//2.3
设置输入框文本

   
textField.text = @"12345";

   
//2.4
设置输入文本颜色,只影响输入框输入文本的颜色

   
textField.textColor = [UIColor redColor];

   
//2.5
设置文本框的对齐格式

   
textField.textAlignment = NSTextAlignmentLeft;

//2.6
设置文本输入框的是否可编辑
//   
textField.enabled = NO;//默认可编辑YES;

   
//关闭用户交互
//   
textField.userInteractionEnabled = NO;

   
   
//2.7
当文本输入框开始输入的时候,清空输入框中的内容,默认为NO,只在第一个起作用
   
textField.clearsOnBeginEditing
= YES;

   
//2.8
设置键盘弹出格式

   
textField.keyboardType = UIKeyboardTypeNumberPad;//纯数字键盘

textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;

//2.9
设置return键的格式

   
textField.returnKeyType = UIReturnKeyDone;

   
//2.10
设置文本输入框是否以加密的形式显示,默认是NO;

   
textField.secureTextEntry = YES;



   
//3.添加到父视图

[contentView addSubview:textField];

   
//4.释放所有权

   
[textField release];
 
  
[contentView release];
   
// Override point for
customization after application launch.

   
self.window.backgroundColor = [UIColor whiteColor];

   
[self.window makeKeyAndVisible];

return
YES;

}
最终效果如下:



#pragma mark
----------UIButton知识点------------

   
//UIButton
是iOS中用来相应点击事件的控制,是UIControl的子类

   
//1.创建UIButton
对象

   
UIButton
*button =
[UIButton
buttonWithType:(UIButtonTypeCustom)];

//UIButtonTypeDetailDisclosure 
详细信息(浅色背景)

   
//UIButtonTypeInfoDark               
详细信息(深色背景)
   
//UIButtonTypeInfoLight               
详细信息(浅色背景)

   
//UIButtonTypeSystem
     
   
  系统样式

   
//UIButtonTypeContactAdd
   
 加号按钮

//UIButtonTypeCustom     
自定义格式,需要添加图片的时候需要使用此种类型

//2.配置属性

button.backgroundColor
=
[UIColor
greenColor];

//2.2
设置button的frame

   
button.frame
=
CGRectMake(10,
300,
300,
60);

//2.3
给button切圆角

   
button.layer.cornerRadius
=
15;

   
//2.4
给button添加标题
   
//注意:给button添加标题时一定要写清楚状态

    [button
setTitle:@"正常状态" forState:UIControlStateNormal];

   

    [button
setTitle:@"高亮状态" forState:UIControlStateHighlighted];

   
 
  [button setTitle:@"不可用状态"
forState:UIControlStateDisabled];

[button
  setTitle:@"选中状态"
forState:UIControlStateSelected];

 
   
//2.5
设置button是否可用

   
//默认是可用状态YES;

 
 //   
button.enabled = NO;

   

   
//2.6 设置button
是否处于选中状态

   
//默认是处于没有选中状态NO,设置为YES处于选中状态
   
button.selected
=
NO;

   
//2.7
设置button上标题的文字大小

   
//button
是一个复合视图(有多个视图构成的视图),其中titleLable
是标题,用来显示标题,还有一个imageView,用来显示图片
   
button.titleLabel.font
=
[UIFont
boldSystemFontOfSize:20];
   
//2.8
设置button标题的颜色

   
button.tintColor
=
[UIColor
redColor];

//2.9
设置button的imageView的图片

   
//UIImage是一个图片类,继承自NSObject

//创建UIImage对象

//   
UIImage *image = [UIImage imageNamed:@"1"];//只有png格式后缀的图片不写后缀,其他的都要写后缀

//   


//   
[button setImage:image forState:UIControlStateNormal
];

   

   
//2.10
设置button背景图片

   
//3.添加到父视图上

[self.window
addSubview:button];

UIImage
*image2 =
[UIImage
imageNamed:@"2.jpg"];

[button setBackgroundImage:image2
forState:UIControlStateNormal];

UIImage
*image3 =
[UIImage
imageNamed:@"3.jpg"];

[button setBackgroundImage:image3
forState:UIControlStateHighlighted];

//buttond的关联时间

//Target
:button指定的响应的对象

   
//action :
指定相应对象调用的方法,方法用来处理button点击事件

   
//ControlEvents
:事件的触发时机,一般用UIControlEventTouchUpInside
   
[button addTarget:self
action:@selector(handleAction:)
forControlEvents:UIControlEventTouchUpInside];//方法有参数handleAction:加冒号
 
  
       
[contentView release];
   
//
Override point for customization after application
launch.

   
self.window.backgroundColor
=
[UIColor
whiteColor];

[self.window
makeKeyAndVisible];

return
YES;

}
//botton点击事件的实现方法
-
(void)handleAction:
(UIButton
*)button{

NSLog(@"鼓掌");

}
===================================================
综合练习:点击Botton把TextField输入的值上传到Label上

-
(BOOL)application:(UIApplication
*)application
didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
   
self.window
=
[[[UIWindow
alloc]
initWithFrame:[[UIScreen
mainScreen]
bounds]]autorelease];
   
 //创建总管视图
   
UIView
*contenView =
[[UIView
alloc]initWithFrame:[UIScreen
mainScreen].bounds];

contenView.tag
=
100;

     
contenView.backgroundColor
=
[UIColor
brownColor];
--------------------------------------------------------------------
  
//建一个label视图
//全局变量要想调用最好的方法是给其视图赋Tag值;



   
UILabel
*lable =
[[UILabel
alloc]initWithFrame:CGRectMake(100,
100,
200,
60)];
   
lable.backgroundColor
=
[UIColor
cyanColor];
   
lable.tag
=
101;
   
[contenView addSubview:lable];

[lable release];

//建一个UItextField

UITextField
*field =
[[UITextField
alloc]initWithFrame:CGRectMake(100,
300,
200,
60)];

field.backgroundColor
=
[UIColor
whiteColor];

field.tag
=
102;

field.borderStyle
=
UITextBorderStyleRoundedRect;

field.textColor
=
[UIColor
redColor];

[contenView addSubview:field];

[field release];

//建一个button的按钮

UIButton
*button =
[UIButton
buttonWithType:UIButtonTypeCustom];

button.frame
=
CGRectMake(150,
400,
100,
60);

button.tintColor
=
[UIColor
magentaColor];

[button setTintColor:[UIColor
blackColor]];

   
button.backgroundColor
=
[UIColor
redColor];
 
 
field.placeholder = @"请输入内容”; 
   
[button setTitle:@"上去"
forState:UIControlStateNormal];
  
   
  //给button添加事件
   
[button addTarget:self
action:@selector(uPStringTopLabel)
forControlEvents:UIControlEventTouchUpInside];//一般都用这个时间条件
   
[contenView addSubview:button];
   
[button release];


   
[self.window
addSubview:contenView];
    
[contenView release];
   
//
Override point for customization after application
launch.

   
self.window.backgroundColor
=
[UIColor
whiteColor];

[self.window
makeKeyAndVisible];

   
return
YES;
}
//点击事件的实现方法
-
(void)uPStringTopLabel{
 
    //获取控件的父视图
   
UIView
*contenView =
[self.window
viewWithTag:100];
//通过父视图获取label
   
UILabel
*label =
(UILabel
*)[contenView
viewWithTag:101];
 //通过父视图获取field
   
UITextField
*field =
(UITextField
*)[contenView
viewWithTag:102];
 
//将field的内容赋值给label
   
label.text
=
field.text;
 
 

欢迎学习本文档,未经博主允许,不得私自转载!

 }

UILabel-UITextField-UIBotton UI_…的更多相关文章

  1. iOS学习21之UILabel, UITextField, UIButton, UIImageView

    1.UILabel 1> 概述 UILabel (标签): 是显示文本的控件.在App中 UILabel 是出现频率最高的控件 UILabel 是 UIView 子类,作为子类一般是为了扩充父类 ...

  2. swift系统学习控件篇:UIbutton+UIlabel+UITextField+UISwitch+UISlider

    工作之余,学习下swift大法.把自己的学习过程分享一下.当中的布局很乱,就表在意这些细节了.直接上代码: UIButton+UILabel // // ViewController.swift // ...

  3. UILabel,UITextField,UIButton三大基础控件总结

    (一)UILabel空件 属性: 1.背景颜色 label.backgroundColor = [UIColor ***]; 2. 显示文字: label.text = @"******&q ...

  4. UILabel,UITextField 以及UIButton应用

    </pre><pre name="code" class="cpp">一.UILabel 它是ioS开发使用的控件来显示文本,它是UIV ...

  5. UI 经常用法总结之--- UILabel UITextField (不断更新中)

    UILabel : UIView <NSCoding> 1.创建一个UILabel对象 UILabel *label = [[UILabel alloc]initWithFrame:CGR ...

  6. UIlabel - 富文本属性

    1.NSKernAttributeName: @10 调整字句 kerning 字句调整 2.NSFontAttributeName : [UIFont systemFontOfSize:_fontS ...

  7. iOS自学-UILabel常见属性

    #import "ViewController.h" #import <CoreText/CoreText.h> @interface ViewController ( ...

  8. (转)UILabel常用属性

    Java代码 收藏代码 #import "ViewController.h" #import <CoreText/CoreText.h> @interface View ...

  9. UI 基本控件使用

    一>UITextFiled  ———>UITextField是什么 UITextField ( 输入框 ) : 是控制文本输入和显示的控件.在APP中UITextField 出现频率很高 ...

  10. [翻译] GONMarkupParser

    GONMarkupParser https://github.com/nicolasgoutaland/GONMarkupParser NSString *inputText = @"Sim ...

随机推荐

  1. python 函数递归

    ##recursive递归 递归特性:1. 必须有一个明确的结束条件2. 每次进入更深一层递归时,问题规模相比上次递归都应有所减少3. 递归效率不高,递归层次过多会导致栈溢出(在计算机中,函数调用是通 ...

  2. 链表的无锁操作 (JAVA)

    看了下网上关于链表的无锁操作,写的不清楚,遂自己整理一部分,主要使用concurrent并发包的CAS操作. 1. 链表尾部插入 待插入的节点为:cur 尾节点:pred 基本插入方法: do{ pr ...

  3. asp.net使用session完成: 从哪个页面进入登录页面,登录成功还回到那个页面

    1.在Login.aspx页面Load中加入 if (!IsPostBack && Request.UrlReferrer != null) {      Session[ " ...

  4. LintCode题解之最长单词

    这些一次遍历搞定的,套路无非都是在遍历的时候就记录数据的状态,然后根据遍历到的当前的数据的状态来修改最终结果,当遍历完了的时候结果也就确定了. public class Solution { /* * ...

  5. oracle伪列

    Oracle的伪列以及伪表 oracle系统为了实现完整的关系数据库功能,系统专门提供了一组成为伪列(Pseudocolumn)的数据库列,这些列不是在建立对象时由我们完成的,而是在我们建立时由Ora ...

  6. windows 7、8分区

    如果你的机器一开始安装的是windows7或者8, 一般分配的分区都是主分区.如果你想再搭配个linux操作系统,搞个双系统啥的,可能总是失败.我有血的教训啊. 从源头上可以解决分区问题,就是可以在安 ...

  7. 关于V4L2中操作比较重要的几个命令以及一般操作流程总结

    最近在做关于摄像头测试程序相关的一些开发,主要是想要实现在摄像头采集视频的过程中,通过按键来实现拍照,然后将拍照得到的数据保存到一个文件中,通过了解V4L2的一些相关操作,原来,拍照后的数据是保存在一 ...

  8. 剑指Offer--排序算法小结

    剑指Offer--排序算法小结 前言 毕业季转眼即到,工作成为毕业季的头等大事,必须得认认真真进行知识储备,迎战笔试.电面.面试. 许久未接触排序算法了.平时偶尔接触到时自己会不假思索的百度,然后就是 ...

  9. 深入理解Express.js

    转自:http://xvfeng.me/posts/understanding-expressjs/ 英文原文更赞:http://evanhahn.com/understanding-express- ...

  10. 深入剖析Tomcat类加载机制

    1JVM类加载机制 JVM的ClassLoader通过Parent属性定义父子关系,可以形成树状结构.其中引导类.扩展类.系统类三个加载器是JVM内置的. 它们的作用分别是: 1)引导类加载器:使用n ...