且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

修复了 UIPickerView 选择栏中的标签

更新时间:2023-12-04 12:26:52

创建您的选择器,创建一个带有阴影的标签,并将其推送到 selectionIndicator 视图下方的选择器子视图.

Create your picker, create a label with a shadow, and push it to a picker's subview below the selectionIndicator view.

看起来像这样


UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(135, 93, 80, 30)] autorelease];
label.text = @"Label";
label.font = [UIFont boldSystemFontOfSize:20];
label.backgroundColor = [UIColor clearColor];
label.shadowColor = [UIColor whiteColor];
label.shadowOffset = CGSizeMake (0,1);
[picker insertSubview:label aboveSubview:[picker.subviews objectAtIndex:5]]; 
//When you have multiple components (sections)...
//you will need to find which subview you need to actually get under
//so experiment with that 'objectAtIndex:5'
//
//you can do something like the following to find the view to get on top of
// define @class UIPickerTable;
// NSMutableArray *tables = [[NSMutableArray alloc] init];
// for (id i in picker.subviews) if([i isKindOfClass:[UIPickerTable class]]) [tables addObject:i];
// etc...

-- 提前付款