我正在设置一个datepicker
代替UITextField
和UIToolbar
的键盘。我希望能够关闭accessoryView
,但它没有按预期运行。虽然我按完成按钮,但未调用操作方法,工具栏格式不是我想要的颜色。
[UIColor defaultAppColor]
应该是红色的,它不会出现在任何地方。
我做错了什么?
UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectZero];
datePicker.datePickerMode = UIDatePickerModeDate;
datePicker.backgroundColor = [UIColor universalGreyColor];
UIToolbar *dobToolbar = [[UIToolbar alloc] init];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(dateSelected:)];
doneButton.tintColor = [UIColor universalActionColor];
UIBarButtonItem *flexibleSeparator = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
dobToolbar.items = @[flexibleSeparator, doneButton];
dobToolbar.barTintColor = [UIColor colorWithWhite:33.0/255.0 alpha:1];
dobToolbar.backgroundColor = [UIColor defaultAppColor];
[dobToolbar setShadowImage:[UIImage new] forToolbarPosition:UIToolbarPositionAny];
//dobToolbar.barStyle = UIBarStyleDefault;
self.dob.inputAccessoryView = dobToolbar;
self.dob.inputView = datePicker;