iOS - UIProgressView、UISlider

2019-01-18  本文已影响10人  小黑Unity_齐xc

头文件

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController{
    UIProgressView* _p;
    UISlider* _s;
}

@property(nonatomic,retain) UIProgressView* p;
@property(nonatomic,retain)UISlider* s;
@end

源文件

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize p = _p;
@synthesize s = _s;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    [self initView];
}

-(void) initView{
    _p = [[UIProgressView alloc]init];
    _p.frame = CGRectMake(100, 100, 200, 5);
    _p.progressTintColor = [UIColor orangeColor];
    _p.progress = 0.5f;
    //设置样式
    _p.progressViewStyle = UIProgressViewStyleDefault;
    [self.view addSubview:_p];
    
    _s = [[UISlider alloc]init];
    _s.frame = CGRectMake(100, 200, 200, 10);
    _s.tintColor = [UIColor greenColor];
    [self.view addSubview:_s];
    
    [_s addTarget:self action:@selector(ss) forControlEvents:UIControlEventValueChanged];
}

-(void) ss{
    NSLog(@"滑动条: %f", _s.value);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end

上一篇 下一篇

猜你喜欢

热点阅读