#import "AppDelegate.h"
#import "ViewController.h"
#import "secondViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// //滑竿
// ViewController *viewController =[[ViewController alloc]init];
// self.window.rootViewController = viewController;
//分段控制器
secondViewController *secondVC = [[secondViewController alloc]init];
self.window.rootViewController = secondVC;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//滑竿的使用
//初始化
UISlider *mySlider =[[UISlider alloc]initWithFrame:CGRectMake(30, 100, 300, 50)];
// [self.view addSubview:mySlider];
//设置滑竿的最小值
mySlider.minimumValue = 0;
//设置滑竿的最大值
mySlider.maximumValue = 100;
//划过范围的颜色
mySlider.minimumTrackTintColor = [UIColor redColor];
//未划过去范围的颜色
mySlider.maximumTrackTintColor = [UIColor blackColor];
//设置滑块的颜色
mySlider.thumbTintColor = [UIColor grayColor];
//设置左边指示图标
mySlider.minimumValueImage = [UIImage imageNamed:@"han30.png"];
//设置右边的指示图标
mySlider.maximumValueImage = [UIImage imageNamed:@"han30.png"];
//设置滑块的起始位置
mySlider.value = 50;
//为滑竿添加触发事件
[mySlider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
//练习:
//滑动滑竿改变视图的背景颜色。通过三个滑竿,分别控制R/G/B三原色
for (int i = 0 ; i<3; i++) {
UISlider *colorSlider = [[UISlider alloc]initWithFrame:CGRectMake(50, 300+i * 50, 300, 50)];
//由于颜色的范围为0~1.0,所以我们将滑竿的取值范围设置为0~1.0;
colorSlider.minimumValue = 0.0;