UISlider、UIStepper、UISegmentControl、UISwitch、UIProgressView、UIActivityIndicatorView
code
UISlider
UISlider *mySlider = [[UISlider alloc] initWithFrame:CGRectMake(80, 100, 250, 35)];
[self.view addSubview: mySlider];
[mySlider release];
[mySlider addTarget:self action:@selector(sliderAction:) forControlEvents: UIControlEventValueChanged];
- (void) changeColor:(UISlider *) slider {
}
property
- minimumTrackTintColor
- maximumTrackTintColor
- thumbTintColor
设置滑块图片(改变滑块大小) - setMaximumTrackImage:forState
- setMinimumTrackImage:forState
- setThumbImage:forState
UIStepper
UIStepper *myStep = [[UIStepper alloc] initWithFrame: CGRectMake(100, 100, 150, 35)];
[self.view addSubview:myStep];
[myStep release];
[myStep addTarget:self action:@selector(stepAction:) forControlEvents:UIControlEventValueChanged];
UISegmentControl
UISegmentedControl *mySegment = [[UISegmentedControl alloc] initWithItems:@[@"angry", @"cymal", @"drink", @"eat"]];
mySegment.frame = CGRectMake(0, 100, 300, 35);
[self.view addSubview:mySegment];
[mySegment release];
[mySegment addTarget:self action:@selector(mySegmentAction:) forControlEvents:UIControlEventValueChanged];
- (void) mySegmentAction:(UISegmentedControl *) segm {
}
property
- selectedSegmentIndex
- momentary
是否显示选中的状态
UISwitch
UISwitch固定大小
UISwitch *mySwitch = [[UISwitch alloc] initWithFrame:CGRectMake( 100, 200, 0, 0)];
[self.view addSubview: mySwitch];
[mySwitch release];
[mySwitch addTarget:self action:@selector(switchAction:) forControlEvents: UIControlEventValueChanged];
property
- onTintColor
开关on时的颜色
- tintColor
开关off时边框的颜色
- thumbTintColor
开关按钮(圆圈)的颜色
- onImage
打开时的图片,iOS7后失效
UIProgressView
UIProgressView *proVw = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
proVw.frame = CGRectMake(100, 500, 200, 20);
proVw.backgroundColor = [UIColor blueColor];
[self.view addSubview: proVw];
[proVw release];
UIActivityIndicatorView
UIActivityIndicatorView *myActivity = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(100, 300, 30, 30)];
// [myActivity setCenter:CGPointMake(160, 140)];
[myActivity setActivityIndicatorViewStyle: UIActivityIndicatorViewStyleGray];
[self.view addSubview: myActivity];
[myActivity startAnimating];