gpt4 book ai didi

iphone - UIPickerView 行颜色

转载 作者:行者123 更新时间:2023-12-03 18:34:35 25 4
gpt4 key购买 nike

有谁知道如何从 iPhone SDK 更改 UIPickerView 控件中行(或行背景)的颜色?类似于下面的行标题,但我也想更改行的颜色:

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;

谢谢。

最佳答案

谢谢诺亚,这正是我所需要的。我想在此处添加代码,以防万一其他人需要(或想要发表评论:)

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view {

CGRect imageFrame = CGRectMake(0.0, 0.0, 15, 15);
UIImageView *label = [[[UIImageView alloc] initWithFrame:imageFrame] **autorelease**];

if (row == 0)
{
label.backgroundColor = [UIColor redColor];
}
if (row == 1)
{
label.backgroundColor = [UIColor blueColor];
}
if (row == 2)
{
label.backgroundColor = [UIColor blackColor];
}
return label;
}

关于iphone - UIPickerView 行颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/310786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com