How to bring UIButton to front of Mapbox view












1














I am using Mapbox SDK (SWIFT) and created my custom map. I added a button and image on the map in storyboard but when I run the application it seems like it is hidden behind. I tried everything including view.bringSubview(toFront:UIimage) and I can't use this function with a UIButton. I even tried sending the map to the backView but it messes up my custom map and still don't see my image or button. Please help! Thank you.










share|improve this question






















  • Share your code, would be helpful in understanding and resolving your issue
    – Satish
    Nov 23 '18 at 5:29










  • @marcoder - When you added the button and image to the mapView, did you ensure that they are child views of the mapView? i.e. Are they indented to the right of the mapView in the outline view in InterfaceBuilder?
    – Magnas
    Nov 23 '18 at 11:22


















1














I am using Mapbox SDK (SWIFT) and created my custom map. I added a button and image on the map in storyboard but when I run the application it seems like it is hidden behind. I tried everything including view.bringSubview(toFront:UIimage) and I can't use this function with a UIButton. I even tried sending the map to the backView but it messes up my custom map and still don't see my image or button. Please help! Thank you.










share|improve this question






















  • Share your code, would be helpful in understanding and resolving your issue
    – Satish
    Nov 23 '18 at 5:29










  • @marcoder - When you added the button and image to the mapView, did you ensure that they are child views of the mapView? i.e. Are they indented to the right of the mapView in the outline view in InterfaceBuilder?
    – Magnas
    Nov 23 '18 at 11:22
















1












1








1







I am using Mapbox SDK (SWIFT) and created my custom map. I added a button and image on the map in storyboard but when I run the application it seems like it is hidden behind. I tried everything including view.bringSubview(toFront:UIimage) and I can't use this function with a UIButton. I even tried sending the map to the backView but it messes up my custom map and still don't see my image or button. Please help! Thank you.










share|improve this question













I am using Mapbox SDK (SWIFT) and created my custom map. I added a button and image on the map in storyboard but when I run the application it seems like it is hidden behind. I tried everything including view.bringSubview(toFront:UIimage) and I can't use this function with a UIButton. I even tried sending the map to the backView but it messes up my custom map and still don't see my image or button. Please help! Thank you.







ios swift mapbox






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 2:33









marcoder

61




61












  • Share your code, would be helpful in understanding and resolving your issue
    – Satish
    Nov 23 '18 at 5:29










  • @marcoder - When you added the button and image to the mapView, did you ensure that they are child views of the mapView? i.e. Are they indented to the right of the mapView in the outline view in InterfaceBuilder?
    – Magnas
    Nov 23 '18 at 11:22




















  • Share your code, would be helpful in understanding and resolving your issue
    – Satish
    Nov 23 '18 at 5:29










  • @marcoder - When you added the button and image to the mapView, did you ensure that they are child views of the mapView? i.e. Are they indented to the right of the mapView in the outline view in InterfaceBuilder?
    – Magnas
    Nov 23 '18 at 11:22


















Share your code, would be helpful in understanding and resolving your issue
– Satish
Nov 23 '18 at 5:29




Share your code, would be helpful in understanding and resolving your issue
– Satish
Nov 23 '18 at 5:29












@marcoder - When you added the button and image to the mapView, did you ensure that they are child views of the mapView? i.e. Are they indented to the right of the mapView in the outline view in InterfaceBuilder?
– Magnas
Nov 23 '18 at 11:22






@marcoder - When you added the button and image to the mapView, did you ensure that they are child views of the mapView? i.e. Are they indented to the right of the mapView in the outline view in InterfaceBuilder?
– Magnas
Nov 23 '18 at 11:22














3 Answers
3






active

oldest

votes


















1














You need to bring it to top of the view



Self.mapview.bringSubview(button)





share|improve this answer





























    1














    Please check below image make sure your Views hierarchy as followed your button should be last in hierarchy



    enter image description here



    Here is my output



    enter image description here



    or if you have button inside view then you can set it to front as



    Self.view.bringSubviewToFront(button)
    or
    button.superview?.bringSubviewToFront(button)



    Make sure you button is not hidden in Storyboard and when your app is running then Capture user Interface and check layers of your Storyboard.






    share|improve this answer































      0














      You can also control the visibility of subviews by using:



      mapview.layer.zPosition = 1
      button.layer.zPosition = 2
      image.layer.zPosition = 2


      You can click on the debug navigator -> View UI hierarchy to visually understand how to view is being layered.



      debug navigator






      share|improve this answer





















        Your Answer






        StackExchange.ifUsing("editor", function () {
        StackExchange.using("externalEditor", function () {
        StackExchange.using("snippets", function () {
        StackExchange.snippets.init();
        });
        });
        }, "code-snippets");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "1"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440003%2fhow-to-bring-uibutton-to-front-of-mapbox-view%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        1














        You need to bring it to top of the view



        Self.mapview.bringSubview(button)





        share|improve this answer


























          1














          You need to bring it to top of the view



          Self.mapview.bringSubview(button)





          share|improve this answer
























            1












            1








            1






            You need to bring it to top of the view



            Self.mapview.bringSubview(button)





            share|improve this answer












            You need to bring it to top of the view



            Self.mapview.bringSubview(button)






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 23 '18 at 2:36









            Anil Kumar

            767




            767

























                1














                Please check below image make sure your Views hierarchy as followed your button should be last in hierarchy



                enter image description here



                Here is my output



                enter image description here



                or if you have button inside view then you can set it to front as



                Self.view.bringSubviewToFront(button)
                or
                button.superview?.bringSubviewToFront(button)



                Make sure you button is not hidden in Storyboard and when your app is running then Capture user Interface and check layers of your Storyboard.






                share|improve this answer




























                  1














                  Please check below image make sure your Views hierarchy as followed your button should be last in hierarchy



                  enter image description here



                  Here is my output



                  enter image description here



                  or if you have button inside view then you can set it to front as



                  Self.view.bringSubviewToFront(button)
                  or
                  button.superview?.bringSubviewToFront(button)



                  Make sure you button is not hidden in Storyboard and when your app is running then Capture user Interface and check layers of your Storyboard.






                  share|improve this answer


























                    1












                    1








                    1






                    Please check below image make sure your Views hierarchy as followed your button should be last in hierarchy



                    enter image description here



                    Here is my output



                    enter image description here



                    or if you have button inside view then you can set it to front as



                    Self.view.bringSubviewToFront(button)
                    or
                    button.superview?.bringSubviewToFront(button)



                    Make sure you button is not hidden in Storyboard and when your app is running then Capture user Interface and check layers of your Storyboard.






                    share|improve this answer














                    Please check below image make sure your Views hierarchy as followed your button should be last in hierarchy



                    enter image description here



                    Here is my output



                    enter image description here



                    or if you have button inside view then you can set it to front as



                    Self.view.bringSubviewToFront(button)
                    or
                    button.superview?.bringSubviewToFront(button)



                    Make sure you button is not hidden in Storyboard and when your app is running then Capture user Interface and check layers of your Storyboard.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 24 '18 at 4:11

























                    answered Nov 23 '18 at 12:00









                    Khush

                    1188




                    1188























                        0














                        You can also control the visibility of subviews by using:



                        mapview.layer.zPosition = 1
                        button.layer.zPosition = 2
                        image.layer.zPosition = 2


                        You can click on the debug navigator -> View UI hierarchy to visually understand how to view is being layered.



                        debug navigator






                        share|improve this answer


























                          0














                          You can also control the visibility of subviews by using:



                          mapview.layer.zPosition = 1
                          button.layer.zPosition = 2
                          image.layer.zPosition = 2


                          You can click on the debug navigator -> View UI hierarchy to visually understand how to view is being layered.



                          debug navigator






                          share|improve this answer
























                            0












                            0








                            0






                            You can also control the visibility of subviews by using:



                            mapview.layer.zPosition = 1
                            button.layer.zPosition = 2
                            image.layer.zPosition = 2


                            You can click on the debug navigator -> View UI hierarchy to visually understand how to view is being layered.



                            debug navigator






                            share|improve this answer












                            You can also control the visibility of subviews by using:



                            mapview.layer.zPosition = 1
                            button.layer.zPosition = 2
                            image.layer.zPosition = 2


                            You can click on the debug navigator -> View UI hierarchy to visually understand how to view is being layered.



                            debug navigator







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 23 '18 at 4:33









                            Alex Bailey

                            370316




                            370316






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440003%2fhow-to-bring-uibutton-to-front-of-mapbox-view%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                What visual should I use to simply compare current year value vs last year in Power BI desktop

                                How to ignore python UserWarning in pytest?

                                Alexandru Averescu