UIDatePicker does not indicate whether it is disabled. This Objective-C category provides a method to visually disable a UIDatePicker.
- Add
UIDatePicker+VisuallyDisabled.h
andUIDatePicker+VisuallyDisabled.m
to your project. - Place
#import "UIDatePicker+VisuallyDisabled.h"
in top of the files where you'd like to disable a UIDatePicker. - Call
[aDatePicker visuallySetEnabled:NO]
to disable a UIDatePicker. ReplaceNO
withYES
to enable it afterwards.
Only one method is available:
- (void)visuallySetEnabled:(BOOL)enabled
When this method is called, the UIDatePicker is enabled or disabled and the alpha
property of the relevant subviews is changed, to visually show whether the control is enabled or disabled. This method should be used instead of the default setEnabled:
method.
The code requires ARC. It has been tested in the iOS Simulator with iOS versions 5.0, 5.1, 6.0 and 6.1, both for iPhone and iPad.
Because the appearance of standard iOS UI elements is changed, Apple might reject apps using this code. Usage of this code is therefore at your own risk.
The code is licensed under MIT license. See LICENSE.txt
for details.