如何删除iPad中日期选择器后面的暗点背景

时间:2012-02-14 06:50:53

标签: iphone objective-c xcode ipad datepicker

我为iPhone开发了一个应用程序。我已将此相同的应用程序移植到iPad。

所有观点都完美无缺。

但是拣选者在他们周围有一个很长的黑暗背景。

即使我改变了IB的尺寸检查员的尺寸

也没改变

我该如何消除这个黑斑?

This is the image of my date picker

3 个答案:

答案 0 :(得分:1)

试试这个:

[[datePicker.subviews objectAtIndex:0] removeFromSuperview];
[datePicker setBackgroundColor:[UIColor clearColor]];

答案 1 :(得分:1)

Hello Ur's Truly Prasad,

实现UIPickerView的更好方法是,有两种方法可以显示UIPicker视图,这种视图更具有可预测性

1)您可以将子视图放在UIAlertview上     以下代码为。

self.actionSheet = [[UIActionSheet alloc] initWithTitle:nil
                                                   delegate:nil
                                          cancelButtonTitle:nil
                                     destructiveButtonTitle:nil
                                          otherButtonTitles:nil];

    [self.actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

    CGRect pickerFrame = CGRectMake(0, 40, 0, 0);

    self.pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];

    self.pickerView.showsSelectionIndicator = YES;
    self.pickerView.userInteractionEnabled=YES;
    self.pickerView.delegate = self;
    self.pickerView.dataSource = self;
    [self.actionSheet addSubview:self.pickerView];

    UIToolbar *controlToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, dateSheet.bounds.size.width, 44)];

    [controlToolBar setBarStyle:UIBarStyleBlack];
    [controlToolBar sizeToFit];

    UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

    UIBarButtonItem * setButton = [[UIBarButtonItem alloc] initWithTitle:@"Set" style:UIBarButtonItemStyleDone target:self action:@selector(dismissDateSet)];
    UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelButton)];

    [controlToolBar setItems:[NSArray arrayWithObjects:spacer, cancelButton, setButton, nil] animated:NO];

    [self.actionSheet showInView:[UIApplication sharedApplication].keyWindow];
    [self.actionSheet addSubview:controlToolBar];
    [self.actionSheet showInView:self.view];
    [self.actionSheet setBounds:CGRectMake(0 ,  20 , 320, 485)];

More that you can go to refrence link here

2)您可以将子视图放在UIPopview控制器上。 and same question for the UIPickerview inside into UIPopovercontroller here.

谢谢和问候,

塞缪尔。

答案 2 :(得分:0)

问题解决了.. - 通过取消选中属性检查器中的“自动调整大小视图”。 在Interface Builder中