步步入佳境---UI入门(4) --简单练习
2013-11-17 19:56
375 查看
一,创建SingleViewApplication
1,UILabel的简单使用
UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 200)];
label.text=@"labelada dsfsfsf sfsf sf sfs fsdfsafs sfsdfs sdfsdf sdfs df sdf sdf ";
label.font=[UIFont fontWithName:@"chalkboard se" size:25];
label.textColor=[UIColor orangeColor];
label.lineBreakMode=NSLineBreakByCharWrapping;
label.numberOfLines=3;//保留的行数
label.highlighted=YES;//文字是否高亮显示
label.highlightedTextColor=[UIColor greenColor];//文字高亮显示的颜色
[label setTextAlignment:NSTextAlignmentCenter];//对齐方式
[self.view addSubview:label];
label.shadowColor=[UIColor blackColor];//设置阴影颜色
label.shadowOffset=CGSizeMake(2, 5);
label.userInteractionEnabled=NO;//是否可以与用户交互
label.backgroundColor=[UIColor redColor];
2,UITextField的简单使用
UITextField *textField=[[UITextField alloc]initWithFrame:CGRectMake(100, 100, 100, 50)];
textField.borderStyle=UITextBorderStyleRoundedRect;//框的样式
[textField setText:@"李长鸿"]; //text值
[textField setTextAlignment:NSTextAlignmentCenter]; //对齐方式
textField.textColor =[UIColor redColor]; //text颜色
[self.view addSubview:textField];
3,UIButton的简单使用
UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(100, 100, 80, 60)];//初始化按钮和边框大小
[button setBackgroundColor:[UIColor whiteColor]]; //设置按钮背景色
[button setTitle:@"李长鸿" forState:UIControlStateNormal];//设置按钮文字
[button setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];//设置按钮文字颜色
button.titleLabel.shadowColor=[UIColor redColor];//设置字体阴影
button.titleLabel.shadowOffset=CGSizeMake(2, 5);//阴影偏移
button.titleLabel.font=[UIFont fontWithName:@"chalkboard se" size:25];//设置字体和大小
[self.view addSubview:button];
4,UIActionSheet的简单使用
首先这个类要实现<UIActionSheetDelegate>协议,写法:@interface ViewController : UIViewController<UIActionSheetDelegate>
//UIAlertView只有一个选择项,相当于windows里的messagebox,UIActionsheet至少有两个选项
//创建ActionSheet需要多个参数
//(1)initWithTitle:设置标题,将会显示在ActionSheet的顶部
//(2)delegate:shezhiActionSheet的一个按钮被按下后,它的delegate会被通知,执行这个delegate的actionSheet:didDismissWithButtonIndex方法将会执行,这里设为self,就可保证我们自己在ViewController.m中写的这个方法被执行.
//(3)cancelButtonTitle:设置取消按钮标题,这个按钮会显示在ActionSheet的最下边
//(4)destructiveButtonTitle:设置第一个确定按钮的标题
//(5)otherButtonTitle:可以设置多个确定按钮,想要添加两个按钮,可以写成
//otherbuttonTitles:@"New Button1",@"New Button2",nil
}
-(void)onClick:(UIButton *)button
{
UIActionSheet *actionSheet=[[UIActionSheet alloc]initWithTitle:@"Do You Love Me?" delegate:self cancelButtonTitle:@"不选择" destructiveButtonTitle:@"Yes,i love you" otherButtonTitles:@"guess", nil];
[actionSheet showInView:self.view];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
//添加点击事件的方法...
}
5,UISlertView的简单使用 //创建一个alert也要许多参数
//1,initWithTitle:设置标题,将会显示在Alert的顶部
//2,message:设置提示消息内容
//3,delegate:设置Alert的委托,这里,我们设置为self
//4,cancelButtonTitle:设置取消按钮的标题
//5,otherButtonTitles:与ActionSheet类似
//[alert show]用于显示
UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"通知" message:@"你来晚了" delegate:self cancelButtonTitle:@"来了" otherButtonTitles:@"我来晚咋啦", nil];
[alertView show];
6,窗口UIWindow
UIWindow有一个比较重要的属性rootViewController,用于装载窗口里面第一个视图.这个属性是UIViewController类型的
UIWindow有一个比较重要的方法makeKeyAndVisible,这个方法的作用是设置当前window为主window,并且将其内容显示出来
1,UILabel的简单使用
UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 200)];
label.text=@"labelada dsfsfsf sfsf sf sfs fsdfsafs sfsdfs sdfsdf sdfs df sdf sdf ";
label.font=[UIFont fontWithName:@"chalkboard se" size:25];
label.textColor=[UIColor orangeColor];
label.lineBreakMode=NSLineBreakByCharWrapping;
label.numberOfLines=3;//保留的行数
label.highlighted=YES;//文字是否高亮显示
label.highlightedTextColor=[UIColor greenColor];//文字高亮显示的颜色
[label setTextAlignment:NSTextAlignmentCenter];//对齐方式
[self.view addSubview:label];
label.shadowColor=[UIColor blackColor];//设置阴影颜色
label.shadowOffset=CGSizeMake(2, 5);
label.userInteractionEnabled=NO;//是否可以与用户交互
label.backgroundColor=[UIColor redColor];
2,UITextField的简单使用
UITextField *textField=[[UITextField alloc]initWithFrame:CGRectMake(100, 100, 100, 50)];
textField.borderStyle=UITextBorderStyleRoundedRect;//框的样式
[textField setText:@"李长鸿"]; //text值
[textField setTextAlignment:NSTextAlignmentCenter]; //对齐方式
textField.textColor =[UIColor redColor]; //text颜色
[self.view addSubview:textField];
3,UIButton的简单使用
UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(100, 100, 80, 60)];//初始化按钮和边框大小
[button setBackgroundColor:[UIColor whiteColor]]; //设置按钮背景色
[button setTitle:@"李长鸿" forState:UIControlStateNormal];//设置按钮文字
[button setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];//设置按钮文字颜色
button.titleLabel.shadowColor=[UIColor redColor];//设置字体阴影
button.titleLabel.shadowOffset=CGSizeMake(2, 5);//阴影偏移
button.titleLabel.font=[UIFont fontWithName:@"chalkboard se" size:25];//设置字体和大小
[self.view addSubview:button];
4,UIActionSheet的简单使用
首先这个类要实现<UIActionSheetDelegate>协议,写法:@interface ViewController : UIViewController<UIActionSheetDelegate>
//UIAlertView只有一个选择项,相当于windows里的messagebox,UIActionsheet至少有两个选项
//创建ActionSheet需要多个参数
//(1)initWithTitle:设置标题,将会显示在ActionSheet的顶部
//(2)delegate:shezhiActionSheet的一个按钮被按下后,它的delegate会被通知,执行这个delegate的actionSheet:didDismissWithButtonIndex方法将会执行,这里设为self,就可保证我们自己在ViewController.m中写的这个方法被执行.
//(3)cancelButtonTitle:设置取消按钮标题,这个按钮会显示在ActionSheet的最下边
//(4)destructiveButtonTitle:设置第一个确定按钮的标题
//(5)otherButtonTitle:可以设置多个确定按钮,想要添加两个按钮,可以写成
//otherbuttonTitles:@"New Button1",@"New Button2",nil
}
-(void)onClick:(UIButton *)button
{
UIActionSheet *actionSheet=[[UIActionSheet alloc]initWithTitle:@"Do You Love Me?" delegate:self cancelButtonTitle:@"不选择" destructiveButtonTitle:@"Yes,i love you" otherButtonTitles:@"guess", nil];
[actionSheet showInView:self.view];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
//添加点击事件的方法...
}
5,UISlertView的简单使用 //创建一个alert也要许多参数
//1,initWithTitle:设置标题,将会显示在Alert的顶部
//2,message:设置提示消息内容
//3,delegate:设置Alert的委托,这里,我们设置为self
//4,cancelButtonTitle:设置取消按钮的标题
//5,otherButtonTitles:与ActionSheet类似
//[alert show]用于显示
UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"通知" message:@"你来晚了" delegate:self cancelButtonTitle:@"来了" otherButtonTitles:@"我来晚咋啦", nil];
[alertView show];
6,窗口UIWindow
UIWindow有一个比较重要的属性rootViewController,用于装载窗口里面第一个视图.这个属性是UIViewController类型的
UIWindow有一个比较重要的方法makeKeyAndVisible,这个方法的作用是设置当前window为主window,并且将其内容显示出来
相关文章推荐
- 步步入佳境---UI入门(3) --单视图控制器
- 步步入佳境---UI入门(2)
- OPEN(SAP) UI5 学习入门系列之二: 最佳实践练习(下)
- OPEN(SAP) UI5 学习入门系列之二: 最佳实践练习(下)
- j2ee 简单网站搭建:(九)jquery datatables + jquery ui dialog 插件使用入门
- 母函数初期简单入门题练习
- 暑期入门练习(简单数论,质数筛选)
- iOS部分-UI基础控件 - 01天 入门 第06课 gif的简单实用
- iOS开发入门之UIPickerView控件的简单使用
- Tensorflow入门练习(简单神经网络的训练过程)
- Android UI 开发入门—线性布局练习
- OPEN(SAP) UI5 学习入门系列之二: 最佳实践练习(上)
- 已经没办法再简单的状压dp入门练习
- 杭电 线段树 (个人整理(基础入门版))(多题练习.)(简单风格)
- 简单搜索练习(一)二分入门 HDU 2141 Can you find it?POJ 2785 4 Value whose Sum is 0
- 【Facebook的UI开发框架React入门之八】Image的使用简单介绍(iOS平台)-goodmao
- jQuery的简单入门练习
- UI入门——UIView的简单介绍
- OPEN(SAP) UI5 学习入门系列之二: 最佳实践练习(上)