2013-07-22 IOS-User Interface
来源:互联网 发布:黑龙江电视台网络直播 编辑:程序博客网 时间:2024/05/21 21:49
熟悉事件处理机制
iOS动画效果
掌握不同ViewController的使用场景,使用方法
iOS的各种设计模式
iOS硬件特性,会硬件编程
网络应用开发,数据持久化,多线程开发
UI加法运算
UITextFiled,常用于显示少量信息的空间
text
textcolor
//
// AppDelegate.h
// UI_1
//
// Created by 0101 on 13-7-22.
// Copyright (c) 2013年 PH. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
UILabel *label1;
UITextField *tf1;
UITextField *tf2;
UIButton *btn;
UILabel *result;
UIWindow *_window;
}
@property (retain, nonatomic) UIWindow *window;
@end
.m文件
CGRect r = CGRectMake(0, 0, 320, 508);//创建一个矩形
//属性的赋值方式
//方式一
self.window = [[[UIWindow alloc]initWithFrame:r]autorelease];
self.window.backgroundColor = [UIColor redColor];
//方式二
UIWindow *aWin = [[UIWindow alloc]initWithFrame:r];//iOS不支持多窗口 iPhone4/4s 320*480像素 iPhone5s 320*508像素 一个App的高度44*44像素 aWin retainCount = 1
self.window = aWin;//aWin retainCount = 2
aWin.backgroundColor = [UIColor grayColor];
[aWin release];//aWin retainCount = 1,此时该 retainCount = 1归Window,但是window的引用计数没有变化它还是1,此时只是控制权归window,单这并不代表它的引用计数归谁,拥有控制权就一定要释放。
//Label 标签
label1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 90, 40, 30)];
label1.backgroundColor = [UIColor whiteColor];
label1.text = @"";
label1.textAlignment = NSTextAlignmentLeft;
[self.window addSubview:label1];
[label1 release];
//TextFiled 文本输入框 tf1
tf1= [[UITextField alloc]initWithFrame:CGRectMake(10, 50, 40, 30)];
tf1.borderStyle = UITextBorderStyleLine;
tf1.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
tf1.keyboardType = UIKeyboardTypeNumberPad;
[self.window addSubview:tf1];
[tf1 release];
//加号label
UILabel *plus = [[UILabel alloc]initWithFrame:CGRectMake(60, 50, 20, 30)];
plus.text = @"+";
plus.backgroundColor = [UIColor clearColor];
plus.textAlignment = NSTextAlignmentCenter;
[self.window addSubview:plus];
[plus release];
//TextFiled 文本输入框 tf2
tf2 = [[UITextField alloc]initWithFrame:CGRectMake(100, 50, 40, 30)];;
tf2.borderStyle = UITextBorderStyleLine;
tf2.keyboardType = UIKeyboardTypeNumberPad;
[self.window addSubview:tf2];
[tf2 release];
//等号
UILabel *equal = [[UILabel alloc]initWithFrame:CGRectMake(150, 50, 20, 30)];
equal.backgroundColor = [UIColor clearColor];
equal.text = @"=";
equal.textAlignment = NSTextAlignmentCenter;
[self.window addSubview:equal];
[equal release];
//计算结果
result = [[UILabel alloc]initWithFrame:CGRectMake(200, 50, 40, 30)];
result.backgroundColor = [UIColor clearColor];
result.textAlignment = NSTextAlignmentCenter;
[self.window addSubview:result];
[result release];
//Button 按钮
btn = [UIButton buttonWithType:(UIButtonTypeRoundedRect)];
btn.frame = CGRectMake(10, 130, 100, 30);
[btn setTitle:@"计算" forState:(UIControlStateNormal)];
[btn setTitle:@"[计算]" forState:UIControlStateHighlighted];
btn.tintColor = [UIColor orangeColor];
//给按钮添加事件
[btn addTarget:self
action:@selector(btnClick)
forControlEvents:(UIControlEventTouchUpInside)];
[self.window addSubview:btn];
//给按钮添加图片
[btn setBackgroundImage:[UIImage imageNamed:@"abc.png"]
forState:UIControlStateNormal];
[self.window makeKeyAndVisible];
return YES;
-(void)btnClick
{
int sum = 0;
sum = [tf1.text intValue] + [tf2.text intValue];
result.text = [NSString stringWithFormat:@"%d",sum];
}
UI编程步骤
1、将各种控件根据需要(是否要创建成全局变量)声明在.h文件中
2、@synthesize window = _window;
3、创建window CGRect r = CGRectMake(0, 0, 320, 508);//创建一个矩形
4、将矩形r赋值给window属性
//方式一 self.window = [[[UIWindow alloc]initWithFrame:r]autorelease];
//方式二 UIWindow *aWin = [[UIWindow alloc]initWithFrame:r]; //aWin retainCount = 1
/*
iOS不支持多窗口
iPhone4/4s 320*480像素
iPhone5 320*508
一个App的高度44*44
*/
self.window = aWin;//aWin retainCount = 2
aWin.backgroundColor = [UIColor grayColor];
[aWin release];//aWin retainCount = 1,此时该 retainCount = 1归Window,但是window的引用计数没有变化它还是1,只是控制权归window,但这并不代表它的引用计数归谁,拥有控制权就一定要释放。
- 2013-07-22 IOS-User Interface
- User Interface Customization in iOS 5
- User Interface Customization in iOS 5
- ios: UI学习总结(user Interface)
- ios: UI学习总结(user Interface) UITextField
- ios: UI学习总结(user Interface)UIButton
- User Interface
- user interface
- iOS 开发学习之 User Interface(1)APP 生命周期
- iOS 开发学习之 User Interface(2)UIWindow 视窗
- iOS 开发学习之 User Interface(9)UITableView
- 《iOS Human Interface Guidelines》——Accessing User Data
- Agile User Interface Development
- DTrace Graphical User Interface
- Using User-Interface Threads
- XML User Interface Language
- User Interface Freeze Milestone
- 一、 User Interface
- Android 主线程和线程之间相互发送消息
- sed替换中使用变量
- adhoc-海量数据多维自助即席查询平台-mdrill项目开源啦
- 月薪三万的中专生给大学生的十大忠告
- 《软件架构设计》学习笔记&摘录(四)
- 2013-07-22 IOS-User Interface
- 安装vmtools for linux
- 【js局部刷新】js局部刷新代码
- Android Compatibility
- oracle 错误收集
- 软件项目管理:通过合理的团队组合提高团队协作效率
- H264 RTP打包发送 2222
- VC++ 实现整个对话框透明的效果SetLayeredWindowAttributes
- 利用SQOOP将数据从数据库导入到HDFS