-presentModalViewController Does not Respect the View's transparency
||Product Version:||4.2.1 (8C148)|
29-Jan-2011 02:00 PM David Wheeler:
When using -presentModalViewController to present a modal view controller whose view has its background set to [UIColor clearColor], said transparency is ignored.
Steps to Reproduce:
• Run the attached sample code in the simulator.
• Rotate the simulator to Landscape orientation
• Tap the "Present Modal View Controller" button
The modal view should be presented but the root view's background should still be visible, though dimmed. This is because the modal view has its background set to [UIColor clearColor] and the presentation style is UIModalPresentationPageSheet.
The root view's background is present and dimmed on either side of the the modal view, but not under the modal view. Instead, the modal view is opaque, a light grey color.
I suppose that it could be argued that the modal view should not have any transparency. However, I ran into this when I aadded a UIPanGestureRecognizer to the toolbar in the modal view, so that I could add a gesture to drag the modal view a bit and it would close.
Steps to Reproduce:
• Back in the app, Tap the "Present Modal View Controller" button again
• Tap the "Change Color" button to change the modal view's background color to blue.
• Tap on the toolbar and drag it down a bit.
• Observe the grey that appears
• Drag the toolbar 100+ pixels down and let go to trigger the dismissal of the modal view.
The background of the root view should appear (dimmed) above the modal view as the modal view is dragged down, as if it was behind it all along. It should continue to be revealed as the modal view is dismissed.
The same opaque grey color is revealed behind the modal view. When the view is dragged far enough to trigger the dimsissal, it slides down and the grey does, too, at the same rate.
I assume that when a modal view is created, a snapshot is taken of the parent view and it is drawn in on either side of the modal view in landscape mode. Behind the modal view, there is no image drawn, or perhaps it is just drawn in in the opaque grey. I like that the parent view is replaced by an image, so that it can be unloaded in the event of a memory warning. However, I think that a complete snapshot of the parent view should be taken and placed below the modal view, so that if the modal view has any transparent parts, or is dragged aside by a gesture, the parent view *appears* to still be in place below it.
As a workaround I will be presenting the view myself, as discussed in these forums:
But I'm sorry to lose the ability to have the parent view removed in the event of a memory warning.
For Open Radar, the sample code is here: http://www.kineticode.com/code/DragModalDialog.zip
Reports posted here will not necessarily be seen by Apple.
All problems should be submitted at bugreport.apple.com before they are posted here.
Please only post information for Radars that you have filed yourself, and please do
not include Apple confidential information in your posts. Thank you!