How can I customize the UIDatePicker and change the text color and background color?

I created a formatted display of a date object in table cells and used a UIDatePicker to edit those values.

But I cannot edit the text tint color and background color.

The first screenshot is the actual unwanted output:

The actual UIDatepicker

Second screenshot is the desired output:

enter image description here

Here is the link to the project: https://www.dropbox.com/sh/m74tnghpqeah8o7/AAA-rMlGe_mhqiuEkDhbApsUa?dl=0

+3


source to share


2 answers


@AziCode

Add the below line to your func updateDatePicker () if you like getting accurate RGB color coding with UiColor

targetedDatePicker.backgroundColor = UIColor.blueColor()
targetedDatePicker.setValue(UIColor.greenColor(), forKeyPath: "textColor")
targetedDatePicker.setValue(0.8, forKeyPath: "alpha")

      



And link to links and code examples for the same examples: - http://blog.deeplink.me/post/81386967477/how-to-easily-customize-uidatepicker-for-ios

Is it possible to change the font color of datePicker in iOS7?

+12


source


Normal I have a good idea, but just change the font color:



[self.datePicker setValue:[UIColor whiteColor] forKeyPath:@"textColor"];
    SEL selector = NSSelectorFromString( @"setHighlightsToday:" );
    NSInvocation *invocation = [NSInvocation invocationWithMethodSignature :
                                [UIDatePicker
                                 instanceMethodSignatureForSelector:selector]];
    BOOL no = NO;
    [invocation setSelector:selector];
    [invocation setArgument:&no atIndex:2];
    [invocation invokeWithTarget:self.datePicker];

      

+2


source







All Articles