图像、开关、滑块、进度条、模式对话框、弹出框(16.5.22)
来源:互联网 发布:java电脑版64位安装包 编辑:程序博客网 时间:2024/05/02 00:11
//图像视图 UIImageView
self.aView = [[[UIImageViewalloc]initWithFrame:CGRectMake(20, 60, 280, 400)]autorelease];
self.aView.image = [UIImageimageNamed:@"akgo"];//设置显示图片,如果图片格式为png,后辍名可不写
self.aView.userInteractionEnabled =NO;//是否响应触摸事件,默认值为NO.一定要记住!!!
[selfaddSubview:self.aView];
self.aView.image = [UIImageimageNamed:@"akgo"];//重置图片
self.aView.backgroundColor = [UIColoryellowColor];//设置背景
self.aView.contentMode = UIViewContentModeCenter;//设置内容填充模式,默认是UIViewContentModeScaleToFill
/**
UIViewContentModeScaleToFill //缩放以填充,图片可能会变形
UIViewContentModeScaleAspectFit //缩放以显示全部,比例不变
UIViewContentModeScaleAspectFill //缩放显示并填满,比例不变,图片可能部分未显示
UIViewContentModeCenter //内容大小不变,居中显示
UIViewContentModeTop //内容大小不变,靠顶部显示
UIViewContentModeBottom //内容大小不变,靠底部显示
UIViewContentModeLeft //内容大小不变,靠左边显示
UIViewContentModeRight //内容大小不变,靠右边显示
UIViewContentModeTopLeft //内容大小不变,靠顶部左边显示
UIViewContentModeTopRight //内容大小不变,靠顶部右边显示
UIViewContentModeBottomLeft //内容大小不变,靠底部左边显示
UIViewContentModeBottomRight //内容大小不变,靠顶部右边显示
//开关 UISwitch
UISwitch *aSwitch = [[[UISwitchalloc]initWithFrame:CGRectMake(20, 20, 10, 10)]autorelease];//这里的宽,高没有实际意义,由系统自定义
aSwitch.onTintColor = [UIColorgreenColor];//打开开关时的背景色
aSwitch.tintColor = [UIColorgrayColor];//关闭开关时的背景色
aSwitch.thumbTintColor = [UIColoryellowColor];//开关滑块的颜色
aSwitch.on = NO;//设置开关关闭状态
[aSwitch addTarget:selfaction:@selector(switchAction:)forControlEvents:UIControlEventValueChanged];//开关值改变的响应方法
[self addSubview:aSwitch];
- (void)switchAction:(UISwitch*)aSwitch
{
if (YES == aSwitch.on)
{
NSLog(@"开关已经打开");
}
else
{
NSLog(@"开关已经关闭");
}
}
//滑块 UISlider
UISlider *aSlider = [[[UISlideralloc]initWithFrame:CGRectMake(50, 50, 220, 10)]autorelease];////这里的高没有实际意义,由系统自定义
aSlider.value = 0.0;//设置起始值
aSlider.minimumValue = 0.0;//设置最小值
aSlider.maximumValue = 1.0;//设置最大值
[aSlider addTarget:selfaction:@selector(sliderAction:)forControlEvents:UIControlEventValueChanged];//设置滑块改变响应方法
[self addSubview:aSlider];
//进度条 UIProgressView
self.progressView = [[[UIProgressViewalloc]initWithFrame:CGRectMake(50, 50, 220, 100)]autorelease];//这里的高度由系统自定义
self.progressView.progress = 0.0;//设置初始值
self.progressView.progressTintColor = [UIColoryellowColor];//设置进度背景颜色
self.progressView.trackTintColor = [UIColorgreenColor];//设置轨道背景颜色
[selfaddSubview:self.progressView];
//模态对话框 UIAlertView
UIAlertView *alertView = [[UIAlertViewalloc]initWithTitle:@"提示"
message:@"当前无网络,请检查你的网络设置"
delegate:nil
cancelButtonTitle:@"好的"
otherButtonTitles:nil];
[alertView show];
[alertView release];
//表单弹出框 UIActionSheet
UIActionSheet *sheet = [[UIActionSheetalloc]initWithTitle:@"分享"
delegate:self
cancelButtonTitle:@"取消"
destructiveButtonTitle:nil
otherButtonTitles:@"新浪微博",@"腾讯微博",@"微信-朋友圈",@"邮件分享",@"短信分享",nil];
[sheet showInView:self];//指定弹出框的父视图
[sheet release];
- 图像、开关、滑块、进度条、模式对话框、弹出框(16.5.22)
- Android滑块开关
- 弹出自定义模式对话框
- android 弹出进度条对话框的方法
- android 弹出进度条对话框的方法
- 滑块(JSlider)与进度条(JProgressBar)
- jquery 进度条 滑块
- 纯css实现开关按钮(滑块)
- 弹出模式对话框和弹出非模式对话框
- DIV全屏-弹出模式对话框
- JavaScript 弹出窗口模式对话框
- 安卓开发:AlertDialog类的使用【弹出对话框、进度条、输入框、单选框、复选框】
- 滑块和进度条范例
- 版本更新时Activity作为对话框形式弹出进度条
- 使用Scroller制作滑块开关ToggleButton
- 使用Scroller制作滑块开关ToggleButton
- ionicCSS05_切换开关和滑块
- WPF CheckBox 滑块 样式 开关
- 指针和引用的区别
- C++ 高级数据类型(一)—— 数组
- Mybatis使用generator自动生成映射配置文件信息
- nginx镜像站操作记录
- php的介绍及Php有什么优势?
- 图像、开关、滑块、进度条、模式对话框、弹出框(16.5.22)
- C++ 高级数据类型(二)—— 字符序列
- C++引用与指针的比较
- Android经验之如何使用ListView
- 33个网站足以使你成为一个天才
- CSS属性集合
- Android中HttpURLConnection使用详解
- C++ 高级数据类型(三)—— 指针
- MathJax 支持的 Latex 符号总结(各种数学字体)