码迷,mamicode.com
首页 > 其他好文 > 详细

UISegmentControl 、UIStepper

时间:2016-02-22 22:09:28      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:

UISegmentControl 、UIStepper

  • UISegmentControl
1.    UISegmentedControl *segmentControl = [[UISegmentedControl alloc] initWithItems:@[@"1",@"2",@"3",@"4"]];
2.segmentControl.frame = (CGRect){50,100,100,50};

等同于

1.    UISegmentedControl *segmentControl = [[UISegmentedControl alloc]
2. initWithFrame:CGRectMake(50, 100, 100, 50)];
3.
4. [segmentControl insertSegmentWithTitle:@"1" atIndex:0 animated:YES];
5. [segmentControl insertSegmentWithTitle:@"2" atIndex:1 animated:YES];
6. [segmentControl insertSegmentWithTitle:@"3" atIndex:2 animated:YES];
7. [segmentControl insertSegmentWithTitle:@"4" atIndex:3 animated:YES];

其监听事件是值改变事件

1.    [segmentControl addTarget:self action:@selector(valueChange:)
2. forControlEvents:UIControlEventValueChanged];
1.-(void)valueChange:(UISegmentedControl *)sender{
2.
3. UIColor *red = [UIColor redColor];
4. UIColor *green = [UIColor purpleColor];
5. UIColor *purple = [UIColor greenColor];
6. UIColor *gray = [UIColor grayColor];
7.
8. NSArray *array = @[red,green,purple,gray];
9.
10. NSInteger index = sender.selectedSegmentIndex;
11. self.view.backgroundColor = array[index];
12.}

技术分享

  • UIStepper

    • 简单了解一些属性
      1.@property(nonatomic) double value;                        // default is 0. sends UIControlEventValueChanged. clamped to min/max
      2.@property(nonatomic) double minimumValue; // default 0. must be less than maximumValue
      3.@property(nonatomic) double maximumValue; // default 100. must be greater than minimumValue
      4.@property(nonatomic) double stepValue; // default 1. must be greater than 0
      5.
 

UISegmentControl 、UIStepper

标签:

原文地址:http://www.cnblogs.com/buakaw/p/5208107.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!