[TIMOB-16597] iOS: Can't create modal transparent Window
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-05-21T20:55:25.000+0000 |
Affected Version/s | Release 3.2.1 |
Fix Version/s | Release 7.3.0 |
Components | iOS |
Labels | backgroundColor, window |
Reporter | carlo |
Assignee | Hans Knöchel |
Created | 2014-03-07T13:58:29.000+0000 |
Updated | 2018-06-22T19:36:44.000+0000 |
Description
Try code above, after animation Window color is reset to Titanium.UI.backgroundColor
var win = Titanium.UI.createWindow({
backgroundColor: 'white',
});
win.open();
var fail = Ti.UI.createWindow({
modal:true,
backgroundColor:'transparent'//or #00FFFFFF
});
fail.add(Ti.UI.createLabel({
text:"Test"
}));
fail.open();//after animation background is black (default)
Attachments
File | Date | Size |
---|---|---|
Testingmodal.zip | 2014-06-24T20:40:59.000+0000 | 34558 |
Moving this ticket to engineering as I can reproduce the issue with the provided test case.
I think we have to setup the parent view controller modal presentation style to use the same view presentation style. Add this: topVC.modalPresentationStyle = UIModalPresentationCurrentContext; before presenting the view controller on -(void)showControllerModal:(UIViewController*)theController animated:(BOOL)animated of TiRootViewController.m Tested it and works with TiSDK 3.2.1, on simulator 7.0.3.
It has nothing to do with the animation of the modal window. Same effect with animated set to false: fail.open({animated:false}); But sure. Looks like the solution is fine.
FWIW, I did change it in 3.1.3GA and we get a transparent bg but it breaks the opening animation (slide up). Any clue ? thanks 3.1.3GA test on simulator 6.1
Could you provider a test case ? Then I will look it up.
Here you go. With the code below, and without adding the line you mention (with UIModalPresentationCurrentContext), animation is ok, transparency is maintained during animation and it all goes black (as expected) at end of animation. Now, modify TiRootViewController with your line and recompile/run the app. When you click the red background, the modal just pops up without tthe slideup animation (but the end result shows the transparency). HTH Thierry
edited: I made a mistake in the previous version, it is of course navwin.open() at the last line not rootwin.open() !
please be aware that with SDK 3.2.2 and SDK 3.2.3 (at least) adding the line to TiRootViewController.m *breaks* the modal slide up animation !! So, the full solution is bound to be more complicated, I am afraid.
[~srahim] to mark as invalid.
This is essentially happening due to the fact that the backgroundColor of the topMostViewcontroller is set to black by default. Which can be changed by using the following code.
Previously we used to present the modal window on top of the viewcontroller stack which was leading to many orientation issues. Since we have moved to the right behavior of presenting the modal viewcontroller on top of the rootViewController. Hence if the backgroundColor of the rootviewController (which is by default black) would show throw the modal view if it's background color is set to 'transparent' The same behavior is shown on native apps too. Native sample app is attached to the project. Marking ticket as invalid.
I find this a bit harsh. There are apps out there who manage to do that natively (Path, for instance). I have tried with transparency of the root window and failed. So could you show me how to adapt the sample I gave for reproduction so that it work with the setBackgroundColor() trick you mention ? Thanks
[~tgo] try the following code snippet
I tested with this and added the setBackgroundColor() to my own test app (see post of 17-may). I agree that it changes the background color. But it still does not show the underlying root window under the tranparent modal. How do you propose to do that with only a color change ? It seems to me that the root cause is that the rootwindow is removed from the display and that's what solved with the trick shown by Giorgios.
give root window the same background color of modal window is not a solution for me! I think you have to consider this issue still open
When you open a modal view controller with the modalPresentationStyle UIModalPresentationFullScreen (always the case on the iPhone and iPod), essentially the presenting view controller removes its view from the hierarchy. This is default behavior. So transparent modal windows are little difficult to do. In Titanium you can always fake the modal screen animations on a regular window by creating appropriate open and close animations for the window. A sample showing the cover vertical behavior is attached below. Going to mark the ticket as Wont Fix.
Triage + Workaround
I change my code so I don't need modal parameter anymore, thanks for code snippets. Finally, we can't create *modal* transparent window. I think this should be reported in docs.
[~bhatfield] FYI.
As Vishal Duggal mentioned: Transparent modal windows are little difficult to do. Same info in the link below, but there is also a workaround/example code. So it's absolute possible. http://www.cocoaosx.com/2011/10/20/how-to-display-transparent-modal-viewcontrollers/
I kind of agree with @Tobias Schibler. I know we can work around the issue but the goal of the titanium framework (at least to me) is that we can have the same behavior without resorting to per OS work arounds ....
@[~colorhat] The code sample shown does not present a ViewController at all. It just adds the childViewControllers view as a subview to the parentViewController view. This is essentially the same as what we do in Titanium when opening a non modal window.
[~vduggal] You make a good work! Thanks a lot. Would be good to have this facts with transparent modal windows in the docs.
Closing ticket as "Won't Fix". There has been no update for a while. If there is any problem, please open a new ticket.
The issue is happening for 6.0.3.GA.
It seems like this is natively possible since iOS 8. [~Andrea.Vitale] made a pull request which is pending review and is scheduled for 7.2.0. Thanks Andrea!
https://github.com/appcelerator/titanium_mobile/pull/10070 exposes MODAL_PRESENTATION_OVER_CURRENT_FULL_SCREEN and MODAL_PRESENTATION_OVER_CURRENT_CONTEXT presentation styles that can solve this issue! Here is an example:
and here a screenshot: http://i65.tinypic.com/2hs5ahz.jpg
*Closing ticket.* fix can be seen in SDK Version:
7.3.0.v20180618182516
*FR (Passed) Test Steps:*Created an application with the code above
Ran the program
waited for animation to take place/app to time out
Noticed the background was transparent unlike before (Would stay black previously)
*Test Environment*