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

077设置分段卡某个选项不可用

时间:2015-06-15 21:59:04      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

效果如下:

技术分享

ViewController.h

1 #import <UIKit/UIKit.h>
2 
3 @interface ViewController : UIViewController
4 @end

ViewController.m

 1 #import "ViewController.h"
 2 
 3 @interface ViewController ()
 4 - (void)layoutUI;
 5 @end
 6 
 7 @implementation ViewController
 8 
 9 - (void)viewDidLoad {
10     [super viewDidLoad];
11     
12     [self layoutUI];
13 }
14 
15 - (void)didReceiveMemoryWarning {
16     [super didReceiveMemoryWarning];
17     // Dispose of any resources that can be recreated.
18 }
19 
20 - (void)layoutUI {
21     UISegmentedControl *smtCContentOffset = [[UISegmentedControl alloc] initWithItems:@[@"First", @"Second", @"Third"]];
22     smtCContentOffset.tintColor = [UIColor colorWithRed:1.000 green:0.434 blue:0.469 alpha:1.000];
23     smtCContentOffset.selectedSegmentIndex = 2;
24     smtCContentOffset.momentary = YES;
25     smtCContentOffset.center = self.view.center;
26     
27     NSLog(@"分段卡的选项个数=%lu", (unsigned long)[smtCContentOffset numberOfSegments]); //分段卡的选项个数=3
28     
29     //设置某个选项不可用
30     [smtCContentOffset setEnabled:NO forSegmentAtIndex:0];
31     NSLog(@"分段卡的第一个选项是否可用?%@", [smtCContentOffset isEnabledForSegmentAtIndex:0] ? @"" : @""); //分段卡的第一个选项是否可用?否
32     [self.view addSubview:smtCContentOffset];
33 }
34 
35 @end

 

077设置分段卡某个选项不可用

标签:

原文地址:http://www.cnblogs.com/huangjianwu/p/4579159.html

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