0
我正在開發使用最新SDK和Xcode 4.2的iOS 4應用程序。在黑色上更改selectedSegment背景顏色UISegmentedControl
我已經在AppDelegate上以編程方式添加了UINavigationController,並將其設置爲黑色。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
viewController.title = @"Menu";
navController = [[UINavigationController alloc] initWithRootViewController:viewController];
navController.navigationBar.tintColor = [UIColor blackColor];
self.window.rootViewController = navController;
[self.window makeKeyAndVisible];
return YES;
}
在一個視圖控制器,我添加了一個UISegmentedControl:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
// Do any additional setup after loading the view from its nib.
segmentedControl = [[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects:
[NSString stringWithString:@"Past"],
[NSString stringWithString:@"Present"],
[NSString stringWithString:@"Future"],
nil]];
[segmentedControl addTarget:self action:@selector(segmentedChanged:) forControlEvents:UIControlEventValueChanged];
segmentedControl.frame = CGRectMake(0, 0, 260, 30);
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.selectedSegmentIndex = 0;
self.navigationItem.titleView = segmentedControl;
}
但是,當我設置一個項目選擇,我可以看到它,因爲是黑色的。
是否有反正當選擇一個項目時設置爲另一種顏色?
您可能會收到來自[這]幫助[1] [1]:http://stackoverflow.com/questions/2270526/uisegmentedcontrol-selected-segment-color – mashios 2011-12-30 12:46:50