• 进度条和滑动条


     1 #import "ViewController.h"
     2 #import "ViewController2.h"
     3 
     4 @interface ViewController ()
     5 
     6 @end
     7 
     8 @implementation ViewController
     9 
    10 @synthesize slider = _slider;
    11 @synthesize pView = _progressView;
    12 
    13 - (void)viewDidLoad {
    14     [super viewDidLoad];
    15 
    16     _progressView = [[UIProgressView alloc]init];
    17     
    18     //进度条的x ,y 宽都可以改变,高不可以变
    19     _progressView.frame = CGRectMake(50, 100, 200, 600);
    20     
    21     //进度条的颜色
    22     _progressView.tintColor=[UIColor redColor];
    23     
    24     _progressView.progress=0.5;
    25     
    26     //
    27     //设置进度条的风格
    28     _progressView.progressViewStyle = UIProgressViewStyleDefault;
    29     
    30     [self.view addSubview:_progressView];
    31     
    32     
    33     
    34     _slider = [[UISlider alloc] init];
    35     
    36     _slider.frame = CGRectMake(50, 200, 200, 10);
    37     
    38     _slider.maximumValue = 1000;
    39     //最小值可以是负值
    40     _slider.minimumValue = 0;
    41     
    42     //_slider.value = 0.5;
    43     
    44     //左侧滑条的颜色
    45     _slider.minimumTrackTintColor = [UIColor grayColor];
    46     //右侧滑条颜色
    47     _slider.maximumTrackTintColor = [UIColor greenColor];
    48     
    49     //滑块颜色
    50     _slider.thumbTintColor = [UIColor redColor];
    51     
    52    [_slider addTarget:self action:@selector(slided) forControlEvents:UIControlEventValueChanged];
    53     
    54     [self.view addSubview:_slider];
    55     
    56 
    57 }
    58 
    59 -(void)slided
    60 {
    61     _progressView.progress = (_slider.value-_slider.minimumValue)/(_slider.maximumValue-_slider.minimumValue);
    62     NSLog(@"value = %f",_slider.value);
    63 }
     1 @interface ViewController : UIViewController
     2 {
     3     //定义一个进度条
     4     UIProgressView* _progressView;
     5     
     6     //滑动条
     7     UISlider* _slider;
     8     
     9 }
    10 
    11 @property(retain,nonatomic) UIProgressView* pView;
    12 
    13 @property(retain,nonatomic) UISlider* slider;
  • 相关阅读:
    Vue的响应式和双向绑定的实现
    JS-跨域请求豆瓣API提供的数据
    豆瓣电影API接口
    JS/PHP-表单文件域上传文件和PHP后台处理
    jQuery-attr,prop及自定义属性
    PHP-关于php代码和html,js混编
    JS-Chrome控制台console.log会访问即时数据
    JS-time和timeEnd
    JS-用ID值直接操作DOM
    CSS-07 行内设置点击事件
  • 原文地址:https://www.cnblogs.com/vector11248/p/7580724.html
Copyright © 2020-2023  润新知