inputAccessoryView无法正常工作或格式化

时间:2015-07-15 16:14:50

标签: ios uitextfield uitoolbar uidatepicker inputaccessoryview

我正在设置一个datepicker代替UITextFieldUIToolbar的键盘。我希望能够关闭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;

0 个答案:

没有答案