基础控件之UILabel、UIButton、UITextField、UIAlertView、 UIImageView
来源:互联网 发布:java定时器 任务超时 编辑:程序博客网 时间:2024/04/30 11:56
基础控件之UILabel、UIButton、UITextField、UIAlertView、UIImageView
UILabel:标签控件,适合一些短的文本
UILable继承于UIView
//把lable对象实例化任何对象都要实例化
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 100, CGRectGetWidth([UIScreen mainScreen].bounds), 50)];
label.text = @"我是贵阳学院的优秀毕业生,我是贵阳学院的优秀毕业生";
label.textAlignment = NSTextAlignmentCenter;
label.text = @"我是贵阳学院的优秀毕业生,我是贵阳学院的优秀毕业生";
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor brownColor];
// 设置字体大小
label.font = [UIFont systemFontOfSize:40.0];
// 在加粗的时候同时设置字体大小
lable.font= [UIFontboldSystemFontOfSize:48];
// 在设置斜体的同时设置字体大写
lable.font= [UIFontboldSystemFontOfSize:48];
// 在设置斜体的同时设置字体大写
lable.font= [UIFontitalicSystemFontOfSize:36];
// 设置阴影颜色
label.shadowColor = [UIColor lightGrayColor];
// 设置阴影偏移量
label.shadowOffset = CGSizeMake(0, -2);
// 给内容设置行数0代表自适应行数,非0是几行就是几行
// label.numberOfLines = 2;
// 自适应字体从而让内容尽量显示一行
label.adjustsFontSizeToFitWidth = YES;
[self.view addSubview:label];
UIButton:按钮点击按钮会触发事件
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];//初始化button设定button的类型
button.frame = CGRectMake(100, 100, 100, 40);//设置坐标
button.backgroundColor = [UIColor grayColor];//设置背景颜色
button.showsTouchWhenHighlighted = YES;//当点击的时候高亮
[button setTitle:@"TickMe" forState:UIControlStateNormal];
[button addTarget:self action:@selector(tickMeDoIt) forControlEvents:UIControlEventTouchUpInside];//设置按钮什么状态下会触发,触发调用什么事件
[self.view addSubview:button];//添加按钮到父视图
UITextField是一个输入控件
UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 100, 40)];//初始化
textField.delegate = self;//添加代理
textField.backgroundColor = [UIColor grayColor];//背景颜色
textField.BorderStyle= UITextBorderStyleLine; //外框类型
textField.placeholder = @"请输入";//默认的占位文字
textField.font = [UIFont systemFontOfSize:20];//设置字号
textField.secureTextEntry = YES; //密码
textField.minimumFontSize = 1.0;//允许调整字体最小的字号
textField.adjustsFontSizeToFitWidth = YES;//允许根据输入框宽度调整字体
textField.returnKeyType = UIReturnKeyDone;//return键的字样
textField.clearButtonMode = UITextFieldViewModeWhileEditing; //编辑时会出现个清空X号
[self.view addSubview:textField];//添加到父视图
UIAlertView是一个提示或警告的弹出窗口
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"密码错误" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];//初始化弹出窗口并赋值
UIButton:按钮点击按钮会触发事件
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];//初始化button设定button的类型
button.frame = CGRectMake(100, 100, 100, 40);//设置坐标
button.backgroundColor = [UIColor grayColor];//设置背景颜色
button.showsTouchWhenHighlighted = YES;//当点击的时候高亮
[button setTitle:@"TickMe" forState:UIControlStateNormal];
[button addTarget:self action:@selector(tickMeDoIt) forControlEvents:UIControlEventTouchUpInside];//设置按钮什么状态下会触发,触发调用什么事件
[self.view addSubview:button];//添加按钮到父视图
UITextField是一个输入控件
UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 100, 40)];//初始化
textField.delegate = self;//添加代理
textField.backgroundColor = [UIColor grayColor];//背景颜色
textField.BorderStyle= UITextBorderStyleLine; //外框类型
textField.placeholder = @"请输入";//默认的占位文字
textField.font = [UIFont systemFontOfSize:20];//设置字号
textField.secureTextEntry = YES; //密码
textField.minimumFontSize = 1.0;//允许调整字体最小的字号
textField.adjustsFontSizeToFitWidth = YES;//允许根据输入框宽度调整字体
textField.returnKeyType = UIReturnKeyDone;//return键的字样
textField.clearButtonMode = UITextFieldViewModeWhileEditing; //编辑时会出现个清空X号
[self.view addSubview:textField];//添加到父视图
UIAlertView是一个提示或警告的弹出窗口
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"密码错误" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];//初始化弹出窗口并赋值
[alertView show];//让alertView显示
// UIImageView用来显示图片
UIImageView *imView = [[UIImageViewalloc]init];
// 如果图片名是png格式的图片名不需要加格式,否则需要加
// imView.image = [UIImage imageNamed:@"1.tiff"];
imView.frame=CGRectMake(80,100,300,300);
[self.windowaddSubview:imView];
// 创建帧动画四要素
// 1.设置间隔时间
// 2.准备图片素材
// 3.设置重复次数
// 4.开始动画
// animationDuration设置动画的时间间隔
imView.animationDuration=1;
// animationImages重获动画
UIImage *img1 = [UIImageimageNamed:@"1.tiff"];
UIImage *img2 = [UIImageimageNamed:@"2.tiff"];
UIImage *img3 = [UIImageimageNamed:@"3.tiff"];
UIImage *img4 = [UIImageimageNamed:@"4.tiff"];
NSArray *array =@[img1,img2,img3,img4];
// 给帧动画准备素材
imView.animationImages= array;
// 给动画设置重复次数使用0无限次循环
// NSNotFound无限大
imView.animationRepeatCount=NSNotFound;
// 动画开始
// 在某个方向上让图片自动适应已达到最好看的效果
imView.contentMode=UIViewContentModeScaleAspectFill;
//
imView.contentMode=
UIViewContentModeScaleToFill;
[imView startAnimating];
// 结束
// [imView stopAnimating];
// 延迟多少秒后执行响应的方法
// 用selector声明的方法一定要实现,否则会奔溃
[selfperformSelector:@selector(start)withObject:nilafterDelay:5];
// 宏定义
// UIScreen指的是屏幕,能帮助我们获取到各种屏幕的宽和高
UIImageView *imView = [[UIImageViewalloc]init];
// 如果图片名是png格式的图片名不需要加格式,否则需要加
// imView.image = [UIImage imageNamed:@"1.tiff"];
imView.frame=CGRectMake(80,100,300,300);
[self.windowaddSubview:imView];
// 创建帧动画四要素
// 1.设置间隔时间
// 2.准备图片素材
// 3.设置重复次数
// 4.开始动画
// animationDuration设置动画的时间间隔
imView.animationDuration=1;
// animationImages重获动画
UIImage *img1 = [UIImageimageNamed:@"1.tiff"];
UIImage *img2 = [UIImageimageNamed:@"2.tiff"];
UIImage *img3 = [UIImageimageNamed:@"3.tiff"];
UIImage *img4 = [UIImageimageNamed:@"4.tiff"];
NSArray *array =@[img1,img2,img3,img4];
// 给帧动画准备素材
imView.animationImages= array;
// 给动画设置重复次数使用0无限次循环
// NSNotFound无限大
imView.animationRepeatCount=NSNotFound;
// 动画开始
// 在某个方向上让图片自动适应已达到最好看的效果
imView.contentMode=UIViewContentModeScaleAspectFill;
//
imView.contentMode=
UIViewContentModeScaleToFill;
[imView startAnimating];
// 结束
// [imView stopAnimating];
// 延迟多少秒后执行响应的方法
// 用selector声明的方法一定要实现,否则会奔溃
[selfperformSelector:@selector(start)withObject:nilafterDelay:5];
// 宏定义
// UIScreen指的是屏幕,能帮助我们获取到各种屏幕的宽和高
NSLog(@"%f",[UIScreenmainScreen].bounds.size.height);
0 0
- 基础控件之UILabel、UIButton、UITextField、UIAlertView、 UIImageView
- UILabel、UITextField、UIButton、UIImageView控件
- iOS基础——UI控件之UIView、UITextField、UILabel、UIColor、UIButton、UIImageView
- UI基本控件-UILabel-UITextField-UIButton-UIAlertView
- UI_基础视图(UILabel UITextField UIButton UIAlertView)
- UI-基本控件( UILabel UITextField UIImageView UIButton)
- UIButton,UIImageView,UILabel,UITextField
- UILabel,UITextField,UIButton,UIimageView
- iOSDay21之UILabel, UITextField, UIButton, UIImageView
- IOS开发UI系列之常用控件 UILabel, UITextField, UIButton, UIImageView等常用属性与方法
- UIView UILabel UITextField UIButton UIImageView 常用属性
- iOS个人整理06-第一周小结,常用控件UIView,UILabel,UIImageView,UIButton,UITextField
- ios 简单基础控件创建汇总:UIBUTTON UILabel UITextField UILabel UIscroll
- UI基础-基础控件-0324-浏览图片案例与改进版(UILabel、UIButton、UIImageView的应用)
- 基础控件使用实例-图片浏览器(UILabel、UIButton、UIImageView及plist)
- 黑马程序员_iOS 的基础控件之UILabel,UISlider,UIImageView
- 黑马程序员_iOS 的基础控件之深入UIButton、UIImageView
- UILabel, UITextField, UIImageView
- 什么是持久化? 为什么要持久化?
- Your build settings specify a provisioning profile with the UUID
- ListView——HolderView方式
- opencv笔记 5.形态学滤波
- python反射机制
- 基础控件之UILabel、UIButton、UITextField、UIAlertView、 UIImageView
- linux 下core文件的设置
- ARM仿真器总结
- 《python识别验证码》
- 避免App沦为“僵尸”的12个秘诀
- Elasticsearch in java 范例:自动补齐功能(completion suggester)
- Python导入自带和外部的包
- 安卓学习记录-java-day3
- iftop ---Linux网络流量监控工具