0
A
回答
1
而不是使用“标题”委托方法,您使用UIView方法,并创建并填充自己的视图。所以你创建一个320宽的UIView(比如说44高),在其中放置一个标签,设置标签的文本和颜色,然后你就可以得到你想要的。
编辑:
#define PICKER_VIEW_SIZE CGSize(300, 40)
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
return PICKER_VIEW_SIZE.height;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
{
return PICKER_VIEW_SIZE.width;
}
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
// assume one component, but this solutions works for multiple
// lets do red, green, and blue alternating backgrounds with alternating black and white text
UIColor *backgroundColor;
switch(row % 3) {
case 0:
default:
backgroundColor = [UICOlor redColor];
break;
case 1:
backgroundColor = [UIColor blueColor];
break;
case 2:
backgroundColor = [UIColor greenColor];
break;
}
UIColor *textColor = (row % 2) ? [UIColor blackColor] : [UIColor whiteColor];
UIView *view = [[UIView alloc] initWithFrame:(CGRect){ {0,0}, PICKER_VIEW_SIZE}];
view.backgroundColor = backgroundColor;
UILabel *label = [UILabel alloc] initWithFrame:CGRectMake(10, 10, 200, 20)];
// configure the label
label.text = text appropriate for this row;
[view addSubview:label];
return view;
}
相关问题
- 1. 改变拾取器的内颜色iphone
- 2. 更改列表视图行的颜色
- 3. 更改视图颜色基于另一个视图的颜色
- 4. CalledFromWrongThreadException:在更改视图颜色时(Android)
- 5. 更改选取器视图的背景颜色
- 6. 如何在MVC视图中更改动态行背景颜色?
- 7. 更改所选行标签颜色选择器视图SWIFT 1.2
- 8. 显示颜色名称的颜色拾取器
- 9. 如何在swift中更改选取器视图的文本颜色?
- 10. 更改选择的视图颜色
- 11. 更改moreNavigationController的颜色配置视图
- 12. 文本视图,更改背景颜色
- 13. 更改视图背景颜色
- 14. 使用SimpleCursorAdapter.ViewBinder更改视图的颜色
- 15. 更改视图颜色的问题
- 16. 更改视图的背景颜色?
- 17. 无法更改视图背景颜色
- 18. 更改自定义视图的颜色
- 19. 通过拾色器更改动态边框颜色在动作脚本3
- 20. javascript中的HTML颜色代码拾取
- 21. 拾色器如何更改TextView
- 22. 更改滚动视图在android的滚动视图的颜色
- 23. 更改Android中新增行的背景颜色列表视图
- 24. 如何更改DataGrid视图中的行颜色
- 25. 如何在运行时更改自定义视图颜色?
- 26. 在刷卡时更改列表视图行的背景颜色
- 27. 用三种颜色每30秒更改视图颜色
- 28. 在绘图视图中更改颜色android
- 29. 在devexpress图表中更改颜色
- 30. 在Primefaces图表中更改颜色
是的,我知道这个方法,但我想,每一个线(行)有不同的颜色。这甚至有可能吗? –
当然有可能!当你被要求查看一行时,你决定使用什么颜色。该委托方法告诉你列和行是什么。你可以使每个视图不同 - 使用不同的背景颜色,字体,文本颜色等。你可以做任何你想要的! –
你能举一些例子吗? –