5

I want to start by saying that i would post this question on the Apple Dev Forums but because of the hacking attempt fiasco , or whatever that was, the forum has been offline for almost 2 weeks now and i need a solution for this as soon as possible.

In iOS 7 the UIDatePicker looks like this : enter image description here

and a client asked to look like this : enter image description here

(basically inverted).

I've tried a few things:

  1. Setting the background to black and looping through all the view's subviews until i reach the labels that show the date itself and change their color to white. The problem is that The view has only one subview, and that subview doesn't have any subviews of it's own. So this solution doesn't work. (it did in ios6).

  2. Applying a filter to the view's CALayer. The thing is that this is only possible on OS X not on iOS, for some unknown reason.

  3. Playing with UIApperance protocol. From what i've read this should work but what i've tried didn't and i don't have extensive experience with this to figure out why not.

Any ideas what i can try? Is this even possible? Did i made a mistake in my approach of the problem?

skytz
  • 2,201
  • 2
  • 18
  • 23
  • Did you ever get this figured out? I'm having the problem. – ijason03 Sep 03 '13 at 19:07
  • @ijason03 no i didn't. it's not possible, or at least not possible for a non-Apple developer. – skytz Sep 04 '13 at 04:25
  • duplicate here: http://stackoverflow.com/questions/20181225/customize-text-color-of-uidatepicker-for-ios7-just-like-mailbox-does – Sig Jan 07 '14 at 04:33

8 Answers8

6

Try this out :

Put this code in -(void)viewDidLoad

[datePicker setValue:[UIColor whiteColor] forKey:@"textColor"];

Swift:

datePicker.setValue(UIColor.white, forKey: "textColor")
aashish tamsya
  • 4,903
  • 3
  • 23
  • 34
3

Don't know if this is still relevant but on Swift 3 / Xcode 8 you can simply do this:

let datePicker = UIDatePicker()
datePicker.datePickerMode = UIDatePickerMode.date

// Sets the text color
datePicker.setValue(UIColor.white, forKey: "textColor")
// Sets the bg color
datePicker.backgroundColor = UIColor.black.withAlphaComponent(0.6)

textField.inputView = datePicker
ygbr
  • 752
  • 9
  • 14
2

I spent quite a bit of time struggling with the same problem. At first, I've put a UIDatePicker on a black background and was wondering why it is invisible...

I ended up placing a white UIView as a background for the date picker, so while the whole view is black, the date picker is white. It actually looks okay, although thankfully I don't have a client who would dictate the design.

One possible argument for a client: the old, pre-iOS7 date picker, also had a predefined non-customisable background.

Sundraw
  • 207
  • 2
  • 11
1

Well I understand your frustration, but iOS7 is under NDA.
Usually this kind of views are made using layers, beacuse of sublayerTransform that can make perspective giving the idea of 3D. I would check sublayers if you don't see subviews.
The other poin is that I would not hack too much views/layers hierachy, ios<=6 to ios7 transition shown that hacking isn't a good idea.
UIAppereance protocol is probably the way to go, becauase it makes you change what you can change (without screwing that in the future), maybe you can set a backgroundImage, try to set a 1x1pixel of a blck color png, you should also see an attributed string property, or text property.

Andrea
  • 26,120
  • 10
  • 85
  • 131
1

What you want is possible, but it will be called Custom Date Picker.

Below is the link where you will find what you wanted.

https://www.cocoacontrols.com/controls/simpledatepicker

If you need more, take a loot at below link.

https://www.cocoacontrols.com/search?utf8=%E2%9C%93&q=datepicker

Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
0

I dont think its possible to do that directly by changing the properties of the default UIDatePicker , although you can use custom controls to do it. This might help,

MWDatePicker - https://github.com/mwermuth/MWDatePicker (Found it in cocoa controls -https://www.cocoacontrols.com/controls/mwdatepicker)

Giridhar
  • 104
  • 1
  • 6
0

according to the iOS Design Resources:

You cannot customize the appearance of date pickers.

I would suggest one of the below:

  • Redesign your UI to use the black text
  • Use a customer datepicker
David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205
LanceJeffrey
  • 452
  • 5
  • 8
0

You should tell your client that his suggestion is against the design principles of iOS 7, which indeed it is. I am not a great fan of iOS 7 myself, but we should all give it a go. Your client should accept the standard iOS 7 UI provisionally, until he is in a position to make an informed judgement. Designing an app based on his initial impressions is a recipe for disaster.

Philip Sheard
  • 5,789
  • 5
  • 27
  • 42
  • 1
    I don't know if it's really against the design principles since the colors of most of the other UI elements can be changed, including the regular UIPicker. But I don't know why Apple would skip the colorizing capability for this one element. – arlomedia May 01 '14 at 22:58