質問

Ok, here is how my app used to look like in iOS 7.0:

Now in iOS 7.1 for some reason it looks like this:

As you can see instead of white blurred background (the greeninsh thing is actually a green UITextField underneath) it is now gray blurred background - if you look closely the green is still visible.

After a lot of experimenting I found out that this is because of a gray layer that is beneath the UIPickerView. Here is the result when I set the hidden property of the UIPickerView to YES:

The code is pretty simple:

_swimlanePicker = [[UIPickerView alloc] initWithFrame:CGRectZero];
_swimlanePicker.delegate = self;
_swimlanePicker.dataSource = self;
[_swimlanePicker setShowsSelectionIndicator:YES];
_swimlaneTextField.inputView = _swimlanePicker;

Do you have any ideas how can I hide (or change the color/transparency of) this gray layer? I liked the old look and want to achieve it in iOS 7.1 too.

役に立ちましたか?

解決

I think it's a problem with the fact that Apple made changes to the appearance of the keyboard. It's sligtly different in iOS 7.1.

A quote from an article presenting changes between the versions (you can see a screenshots with the keyboards before and after).

Apple has also made subtle changes to the keyboard. The font is slightly more bold. The shift and delete buttons have also been tweaked slightly. The background of the keyboard also seems to be slightly lighter than in iOS 7. It seems to add more contrast and makes the letters easier to see.

So I guess you can't do anything without a really ugly hack, like messing around with the underlying CALayers.

You can read about how to add a translucent layer from this answer. A comment from the first approach from the link:

I ran this approach by an Apple UIKit engineer this week at their Tech Talks lab. While he certainly would not endorse this approach, he recognized the need for the effect and the lack of real public API for this, and said that this approach was the "least evil" option for now and is fairly safe as written. Specifically he said do not try to do any animations of the frame or transform of this toolbar/view or anything like that, or bad things will happen. He also strongly suggested to file Radar bug reports on this, to build a case internally so we can get a real public API for this effect!

他のヒント

I had the same problem and it took me some hours to find a very simple solution.

Basically put the picker in a view with your desired backgroundColor. Add this view as your inputView. AND: Don't set the textfields keyboardAppearance to dark!

let datePicker = UIDatePicker()

let datePickerBackground = UIView(frame:CGRect(x:0.0, y:0.0, width:0.0, height:216.0))
datePickerBackground.autoresizingMask = .FlexibleWidth
datePickerBackground.backgroundColor = UIColor.redColor()
datePickerBackground.addSubview(datePicker)

let textField = UITextField(frame: CGRect(x: 0.0, y: 0.0, width: 100.0, height: 50.0))
textField.keyboardAppearance = .Default // Don't set it to .Dark!
textField.inputView = datePickerBackground
addSubview(textField)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top