Titanium JIRA Archive
Appcelerator Community (AC)

[AC-4889] iOS: Can't create modal transparent Window

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2017-04-04T14:08:28.000+0000
Affected Version/sAppcelerator Studio 4.5.0
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsbackgroundColor, window
Reportercarlo
AssigneeShak Hossain
Created2017-03-31T13:05:01.000+0000
Updated2017-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

FileDateSize
Testingmodal.zip2017-03-31T13:05:02.000+000034558

Comments

  1. Ritu Agrawal 2014-03-10

    Moving this ticket to engineering as I can reproduce the issue with the provided test case.
  2. Giorgos Papadopoulos 2014-03-15

    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.
  3. Tobias Høegh 2014-04-29

    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.
  4. Thierry Godfroid 2014-05-16

    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
  5. Giorgos Papadopoulos 2014-05-17

    Could you provider a test case ? Then I will look it up.
  6. Thierry Godfroid 2014-05-17

    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
       var navwin, modalnavwin, rootwin, rootmodalwin;
       rootmodalwin = Ti.UI.createWindow({
       	backgroundColor: '#7F00CCCC'
       });
       modalnavwin = Ti.UI.iOS.createNavigationWindow({
       	modal: true,
       	window: rootmodalwin
       });
       rootmodalwin.addEventListener('click',function(){ 'use strict';
       	modalnavwin.close();
       });
       rootwin = Ti.UI.createWindow({
       	backgroundColor: 'red'
       });
       rootwin.add( Ti.UI.createImageView({
       	width: 300,
       	height: 200,
       	image: 'http://www.appcelerator.com/wp-content/uploads/film_reel@2x.png'
       }));
       navwin = Ti.UI.iOS.createNavigationWindow({
       	window: rootwin
       });
       rootwin.addEventListener('click', function(){ 'use strict';
       	modalnavwin.open();
       });
       navwin.open()
       
    edited: I made a mistake in the previous version, it is of course navwin.open() at the last line not rootwin.open() !
  7. Thierry Godfroid 2014-05-25

    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.
  8. Ingo Muschenetz 2014-06-02

    [~srahim] to mark as invalid.
  9. Thierry Godfroid 2014-06-25

    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
  10. Thierry Godfroid 2014-06-30

    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.
  11. carlo 2014-09-02

    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
  12. carlo 2014-09-08

    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.
  13. Ingo Muschenetz 2014-09-08

    [~bhatfield] FYI.
  14. Tobias Høegh 2014-09-08

    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/
  15. Thierry Godfroid 2014-09-08

    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 ....
  16. Tobias Høegh 2014-09-09

    [~vduggal] You make a good work! Thanks a lot. Would be good to have this facts with transparent modal windows in the docs.
  17. Lee Morris 2017-03-30

    Closing ticket as "Won't Fix". There has been no update for a while. If there is any problem, please open a new ticket.
  18. carlo 2017-03-31

    Same behavior in 6.0.3

JSON Source