[AC-4889] iOS: Can't create modal transparent Window
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2017-04-04T14:08:28.000+0000 |
Affected Version/s | Appcelerator Studio 4.5.0 |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | backgroundColor, window |
Reporter | carlo |
Assignee | Shak Hossain |
Created | 2017-03-31T13:05:01.000+0000 |
Updated | 2017-04-04T14:08:28.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 | 2017-03-31T13:05:02.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.
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
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
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 ....
[~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.
Same behavior in 6.0.3