我想开发一个应用程序,我想以横向方式制作选择器。或者以这种方式调整数组。
如下图所示: -
我有这种观点。它完美地工作这是我想要的功能。但我怎么能保持这样的图像(橙色指针在选定的数字和圆形的矩形图像下橙色指针)。 http://isujith.wordpress.com/2009/03/17/horizontal-uipickerview/ 请指导我如何做到这一点。
以上问题的解决方案是: -
self.view.backgroundColor = [UIColor blackColor];
CGFloat width = 200.0f;
CGFloat x = (self.view.frame.size.width - width) / 2.0f;
CGRect tmpFrame = CGRectMake(x, 150.0f, width, 40.0f);
pickerView = [[V8HorizontalPickerView alloc] initWithFrame:tmpFrame];
pickerView.backgroundColor = [UIColor darkGrayColor];
pickerView.selectedTextColor = [UIColor whiteColor];
pickerView.textColor = [UIColor grayColor];
pickerView.delegate = self;
pickerView.dataSource = self;
pickerView.elementFont = [UIFont boldSystemFontOfSize:14.0f];
pickerView.selectionPoint = CGPointMake(60, 0);
// add carat or other view to indicate selected element
UIImageView *indicator = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"indicator"]];
pickerView.selectionIndicatorView = indicator;
// pickerView.indicatorPosition = V8HorizontalPickerIndicatorTop; // specify indicator's location
[indicator release];
// add gradient images to left and right of view if desired
// UIImageView *leftFade = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"left_fade"]];
// pickerView.leftEdgeView = leftFade;
// [leftFade release];
//
// UIImageView *rightFade = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"right_fade"]];
// pickerView.rightEdgeView = rightFade;
// [rightFade release];
[self.view addSubview:pickerView];
self.nextButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
tmpFrame = CGRectMake(x, 225.0f, width, 50.0f);
nextButton.frame = tmpFrame;
[nextButton addTarget:self
action:@selector(nextButtonClicked:)
forControlEvents:UIControlEventTouchUpInside];
[nextButton setTitle:@"Center Element 0" forState:UIControlStateNormal];
nextButton.titleLabel.textColor = [UIColor blackColor];
[self.view addSubview:nextButton];
self.reloadButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
tmpFrame = CGRectMake(x, 300, width, 50.0f);
reloadButton.frame = tmpFrame;
[reloadButton addTarget:self
action:@selector(reloadButtonClicked:)
forControlEvents:UIControlEventTouchUpInside];
[reloadButton setTitle:@"Reload Data" forState:UIControlStateNormal];
[self.view addSubview:reloadButton];
tmpFrame = CGRectMake(x, 375, width, 50.0f);
infoLabel = [[UILabel alloc] initWithFrame:tmpFrame];
infoLabel.backgroundColor = [UIColor blackColor];
infoLabel.textColor = [UIColor whiteColor];
infoLabel.textAlignment = UITextAlignmentCenter;
[self.view addSubview:infoLabel];
这将与我合作并提供此类型的选择器: -
答案 0 :(得分:2)
您可能无法使用链接中的文章使用的标准选择器执行此操作。您无法轻易更改选择器显示其选择的方式。您需要自己完全编写此组件。