您的位置:首页 > 产品设计 > UI/UE

UIControl

2016-05-09 21:15 471 查看
UISwitch->UIControl->UIView

1、实例化

UISwitch* switch1 = [[UISwitch alloc] initWithFrame:CGRectMake(20, 50, 1000, 2000)];

2、添加

[self.view addSubview:switch1];

3、开关状态

switch1.on = YES;

4、设置颜色 onTintColor description: The color used to tint the appearance of the switch when it is turned on.

switch1.onTintColor = [UIColor yellowColor];

5、设置开关颜色 tintColor description: The color used to tint the outline of the switch when it is turned off.

6、添加事件

[switch1 addTarget:self action:@selector(switchClick:) forControlEvents:UIControlEventValueChanged];

UIActivityIndicatorView->UIView

1、实例化 UIActivityIndicatorView* activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

2、中点

activity.center = CGPointMake(100,100);

3、开始动画

[activity startAnimating];

4、结束动画

[activity stopAnimating];

5、添加

[self.view addSubview:activity];

6、系统加载小菊花

[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

UIStepper->UIControl->UIView

1、实例化

UIStepper *step = [[UIStepper alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];

2、添加

[self.view addSubview:step];

3、设置最大值

step.maximumValue = 100;

4、设置最小值

step.minimumValue = 0;

5、设置初始值

step.value = 50;

6、设置递变量

step.stepValue = 8;

7、添加操作

[step addTarget:self action:@selector(stepClick:) forControlEvents:UIControlEventValueChanged];

注意观察事件为UIControlEventValueChanged

UIProgressView->UIView

1、初始化

UIProgressView* progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(30, 210, 260, 0)];

2、添加

[self.view addSubview:progressView];

3、设置初始值 progress //进度条的取值范围0.0-1.0

progressView.progress = 0.5;

4、设置进度条颜色 tintColor

progressView.tintColor = [UIColor greenColor];

UISlider->UIControl->UIView

1、实例化

UISlider* slider = [[UISlider alloc] initWithFrame:CGRectMake(30, 240,260 ,30)];

2、设置最大值

slider.maximumValue = 100;

3、设置最小值

slider.minimumValue = 0;

4、初始化

slider.value = 50;

5、是否及时更新

slider.continuous = NO;

6、添加

[self.view addSubview:slider];

UISegmentedControl->UIColor->UIView

1、实例化

NSArray* array = @[@”第一个”,@”第二个”,@”第三个”];//数组中的值可为图片或文字

UISegmentedControl* segment = [[UISegmentedControl alloc] initWithItems:array];

2、btn颜色

segment.tintColor = [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:0.8];

3、默认选中

segment.selectedSegmentIndex = 1;

4、新增选项

[segment insertSegmentWithTitle:@”第四个” atIndex:3 animated:NO];

以上为对UISwitch、UIActivityIndicatorView、UIStepper、UISlider、UIProgress、UISegmentedControl的总结
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: