【发布时间】:2014-02-12 11:14:53
【问题描述】:
我有一个包含两个分段控件的项目。他们都工作到了iOS7.0。现在一个没有。我读过有关 tintColor 的问题,但我认为这是不同的。
两个控件都使用 UIImages 作为段。一方面,图像都正确显示。另一方面,我得到所有 蓝色 图像。
是我做错了什么还是这是一个错误?
这是故障段的代码:
UISegmentedControl *colorControl = [[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects:
[UIImage imageNamed:@"White.png"],
[UIImage imageNamed:@"Red.png"],
[UIImage imageNamed:@"Yellow.png"],
[UIImage imageNamed:@"Green.png"],
[UIImage imageNamed:@"Blue.png"],
[UIImage imageNamed:@"Purple.png"],
[UIImage imageNamed:@"Black.png"], nil]];
CGRect frame = CGRectMake(rect.origin.x + kLeftMargin, rect.size.height - kPaletteHeight - kTopMargin, rect.size.width - (kLeftMargin + kRightMargin), kPaletteHeight );
colorControl.frame = frame;
// Add DoubleTap Color capability
gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showMoreColors:)];
[gesture setNumberOfTapsRequired:2];
[colorControl addGestureRecognizer:gesture];
// When the user chooses a color, the method changeColor: is called.
[colorControl addTarget:self action:@selector(changeColor:) forControlEvents:UIControlEventValueChanged];
// Make sure the color of the color complements the black background
//colorControl.tintColor = [UIColor clearColor];
// Add the control to the window
[self.view addSubview:colorControl];
虽然图像都是蓝色的,但片段按预期工作。
【问题讨论】: