UISegmentedController的使用(个人记录)

1.首先在相应的xib文件中添加Segmented Control控件


UISegmentedController的使用(个人记录)
 

效果如下:


UISegmentedController的使用(个人记录)

 

2.对三组控件进行连线:

@property (retain, nonatomic) IBOutlet UISegmentedControl *segmentedHkfs;

@property (retain, nonatomic) IBOutlet UISegmentedControl *segmentedDklb;

@property (retain, nonatomic) IBOutlet UISegmentedControl *segmentedJsfs;

 

3.然后对这三组控件进行数据初始化

[_segmentedHkfs removeAllSegments];
    [_segmentedHkfs insertSegmentWithTitle:@"等额本息" atIndex:0 animated:YES];
    [_segmentedHkfs insertSegmentWithTitle:@"等额本金" atIndex:1 animated:YES];
    //设置默认选项
    _segmentedHkfs.selectedSegmentIndex = 0;

 

[_segmentedDklb removeAllSegments];
    [_segmentedDklb insertSegmentWithTitle:@"商业贷款" atIndex:0 animated:YES];
    [_segmentedDklb insertSegmentWithTitle:@"公积金贷款" atIndex:1 animated:YES];
    [_segmentedDklb insertSegmentWithTitle:@"组合贷款" atIndex:2 animated:YES];
    //设置默认选项
    _segmentedDklb.selectedSegmentIndex = 0;

 

[_segmentedJsfs removeAllSegments];
    [_segmentedJsfs insertSegmentWithTitle:@"面积单价" atIndex:0 animated:YES];
    [_segmentedJsfs insertSegmentWithTitle:@"贷款总额" atIndex:1 animated:YES];
    //设置默认选项
    _segmentedJsfs.selectedSegmentIndex = 1;

 

效果如下:


UISegmentedController的使用(个人记录)
 

 

你可能感兴趣的:(UISegmentedController的使用(个人记录))