如何使用SDK 7在UIPickerView
7上设置iOS 7的背景色,并在iOS 5和6上使用标准选择器?默认情况下,它在iOS 7上是透明的。
发布于 2013-10-01 18:33:02
我在UIView
下添加了UIPickerView
的代码:
CGRect framePickerView = CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, 216);
pickerView = [[[UIView alloc] initWithFrame:framePickerView] autorelease];
pickerView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:pickerView];
[pickerView addSubview:picker];
相反,代码是:
[self.view addSubview:picker];
发布于 2013-10-21 20:52:05
怎么回事:
[picker setBackgroundColor:[UIColor whiteColor]];
如果要调用选择器视图,则假设它是UIView的子类,因此backgroundColor
是一个有效的属性.
发布于 2013-10-01 17:02:47
我想把它写成评论,但很难读懂:)……
-(UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 44)]; // your frame, so picker gets "colored"
label.backgroundColor = [UIColor lightGrayColor];
label.textColor = [UIColor blackColor];
label.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:18];
label.text = [NSString stringWithFormat:@"%d",row];
return label;
}
此外,它不一定只需要标签,我认为你可以插入其他子视图以及.据我所知,它适用于iOS7
https://stackoverflow.com/questions/19121799
复制相似问题