标签:
UISegmentedControl中一些常见的属性和用法
//设置以图案作为分段的显示,仅需要图案的轮廓,这样颜色为分段的背景颜色
// NSArray *items = @[[UIImage imageNamed:@"segmented1"],[UIImage imageNamed:@"segmented_4"],[UIImage imageNamed:@"segmented_3"],[UIImage imageNamed:@"segmented_2"]];
NSArray *items = @[@"视频",@"音乐",@"图片",@"软件"];
// [[UISegmentedControl appearance]setBackgroundImage:items forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
UISegmentedControl *segmentedC =[[UISegmentedControl alloc]initWithItems:items];
//设置第几索引分段为图片
[segmentedC setImage:[UIImage imageNamed:@"segmented_4"] forSegmentAtIndex:2];
//设置默认的第几索引分段为不可选
[segmentedC setEnabled:NO forSegmentAtIndex:2];
//设置第几分段的宽度大小
// [segmentedC setWidth:10.0 forSegmentAtIndex:1];
// [segmentedC setTitleTextAttributes:unselectedTextAttributes forState:UIControlStateNormal];
// segmentedC.backgroundColor = [UIColor brownColor];
//设置点击分段是否恢复原来的样子,默认为NO
// segmentedC.momentary = YES;
//改变低级分段的内容
[segmentedC setTitle:@"YES" forSegmentAtIndex:0];
//设置为圆角的矩形
segmentedC.layer.cornerRadius = 20;
//设置四个圆角有边界的虚线
segmentedC.layer.masksToBounds = YES;
segmentedC.selectedSegmentIndex = 1; //默认选中第几个分割段
// segmentedC.tintColor = [UIColor yellowColor]; //设置分割段边界和字体的颜色
segmentedC.frame =CGRectMake(5, 20, 310, 40);
//设置点击索引分段时的反应
[segmentedC addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
[self.window addSubview:segmentedC];
[segmentedC release];
IOS UI segmentedControl UISegmentedControl 常见属性和用法
标签:
原文地址:http://www.cnblogs.com/meixian/p/4582406.html