IOS开发之XCode学习012:Slider和ProgressView
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm
此工程文件实现功能:
1、定义UISlider和UIProgressView对象和属性
2、设置UISlider和UIProgressView的基本属性,如颜色
3、向UISlider添加事件函数,UIProgressView没有事件函数,只能被动显示进度值
===========================ViewController.h脚本==============================
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
//进度条对象
//一般用来表示下载或视频播放的进度
UIProgressView* _progressView;
//滑动条的定义
//一般用来进行调整进度,如音乐等
UISlider* _slider;
}
//定义一个进度条属性
@property (retain,nonatomic)UIProgressView* progressView;
//定义一个滑动条属性
@property (retain,nonatomic)UISlider* slider;
@end
===========================ViewController.m脚本==============================
@synthesize slider = _slider;
@synthesize progressView = _progressView;
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//进度条的创建
_progressView = [[UIProgressView alloc] init];
//进度条的位置大小设置
//进度条的高度是不可以变化的,40为无效值
_progressView.frame = CGRectMake(50, 100, 200, 40);
//设置进度条的风格色值
_progressView.progressTintColor = [UIColor redColor];
_progressView.trackTintColor = [UIColor blackColor];
//设置进度条的进度值
//范围从0~1
//最小值为0
//最大值为1
_progressView.progress = 0.5;
//设置进度条的风格特征
_progressView.progressViewStyle = UIProgressViewStyleBar;//UIProgressViewStyleDefault;
[self.view addSubview:_progressView];
//创建滑动条对象
_slider = [[UISlider alloc] init];
//位置设置,高度不可变更
_slider.frame = CGRectMake(10, 200, 300, 40);
//设置滑动条最大值
_slider.maximumValue = 100;
//设置滑动条的最小值,可以为负值
_slider.minimumValue = -100;
//设置滑动条的滑块的位置float值
_slider.value = 0.5;
//左侧滑条背景颜色
_slider.minimumTrackTintColor = [UIColor blueColor];
//右侧滑条背景颜色
_slider.maximumTrackTintColor = [UIColor greenColor];
//设置滑块的颜色
_slider.thumbTintColor = [UIColor orangeColor];
//对滑动条添加事件函数
[_slider addTarget:self action:@selector(pressSlider) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:_slider];
}
-(void)pressSlider
{
_progressView.progress = (_slider.value-_slider.minimumValue) / (_slider.maximumValue - _slider.minimumValue);
NSLog(@"value = %f",_slider.value);
}
学习总结:
- 重点:进度条河滑动条的属性
- 难点:进度条河滑动条的使用
源码链接地址:https://pan.baidu.com/s/1yrOLXZZeu9MiOWtMq5-EGA 密码:7t1l
IOS开发之XCode学习012:Slider和ProgressView的更多相关文章
- IOS开发之XCode学习011:UISwitch控件
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能: 1.定义UIswitch控件,添加UIswitc ...
- IOS开发之XCode学习009:UIViewController使用
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能: 通过点击屏幕事件,调用ViewController ...
- IOS开发之XCode学习008:UIViewController基础
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 红色框选部分用A代替,AppDelegate类在程序框架启动时,如果在i ...
- IOS开发之XCode学习007:UIWindow对象
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm #import "AppDelegate.h" @i ...
- IOS开发之XCode学习010:定时器和视图对象
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能: 1.通过点击"启动定时器"按钮 ...
- IOS开发之XCode学习013:步进器和分栏控件
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能: 1.定义UIStepper和UISegmente ...
- IOS开发之XCode学习014:警告对话框和等待提示器
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能: 1.警告对话框和等待提示器的概念 2.警告对话框 ...
- iOS开发之Xcode常用调试技巧总结
转载自:iOS开发之Xcode常用调试技巧总结 最近在面试,面试过程中问到了一些Xcode常用的调试技巧问题.平常开发过程中用的还挺顺手的,但你要突然让我说,确实一脸懵逼.Debug的技巧很多,比如最 ...
- 李洪强iOS开发之Xcode快捷键
14个Xcode中常用的快捷键操作 在Xcode 6中有许多快捷键的设定可以使得你的编程工作更为高效,对于在代码文件中快速导航.定位Bug以及新增应用特性都是极有效的. 当然,你戳进这篇文章的目的 ...
随机推荐
- location对象浅探
- ipset批量配置iptables
简介: ipset是iptables的扩展,允许你创建匹配整个地址sets(地址集合)的规则.而不像普通的iptables链是线性的存储和过滤,ip集合存储在带索引的数据结构中,这种集合比较大也可以进 ...
- angular+require前端项目架构搭建
app //应用入口 directive //自定义指令 require-main //require的主配置文件 存放公共调用的js service //请求后端数据公有类 controllers ...
- gerrit+nginx+centos安装配置
安装环境 centos 6.8 gerrit-full-2.5.2.war 下载地址:https://gerrit-releases.storage.googleapis.com/gerrit-ful ...
- centos/linux下的安装git
1.下载git wget https://github.com/git/git/archive/v2.14.1.zip 2.安装依赖 sudo yum -y install zlib-devel op ...
- org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/lonecloud/tomcat/apache-tomcat-7.0.70 2/webapps/myproject/WEB-INF/classes/cn/lone
解决这个报错的解决办法: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidat ...
- ubuntu17.10 python3.6 install plugins for AI
install order: tensorflow-gpu scikit-learn numpy scipy matplotlib tkinter tensorflow-gpu : pip insta ...
- java9 - 异常处理
Java异常 1.异常初见 System.out.println(1/0); 运行上面语句之后打印出: Exception in thread "main" java.lang.A ...
- 老男孩Python全栈开发(92天全)视频教程 自学笔记18
day18课程内容: os模块 import osprint(os.getcwd())#D:\untitled\练习题 获取当前工作目录os.chdir(r'D:\untitled\练习题\16.1切 ...
- 【转载】什么是Windows USB设备路径,它是如何格式化的?
http://blog.csdn.net/kingmax54212008/article/details/77837210 用于接口的复合USB设备路径格式 \?usb#vid_ vvvv&p ...