我正在datepicker
为 aUITextField
和UIToolbar
. 我希望能够关闭accessoryView
,但它没有按应有的方式运行。尽管我按下了Done按钮,但没有调用操作方法,并且工具栏格式不是我想要的颜色。
[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;