How to bring UIButton to front of Mapbox view
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
add a comment |
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 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
add a comment |
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
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
ios swift mapbox
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
add a comment |
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
add a comment |
3 Answers
3
active
oldest
votes
You need to bring it to top of the view
Self.mapview.bringSubview(button)
add a comment |
Please check below image make sure your Views hierarchy as followed your button should be last in hierarchy
Here is my output
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.
add a comment |
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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
You need to bring it to top of the view
Self.mapview.bringSubview(button)
add a comment |
You need to bring it to top of the view
Self.mapview.bringSubview(button)
add a comment |
You need to bring it to top of the view
Self.mapview.bringSubview(button)
You need to bring it to top of the view
Self.mapview.bringSubview(button)
answered Nov 23 '18 at 2:36
Anil Kumar
767
767
add a comment |
add a comment |
Please check below image make sure your Views hierarchy as followed your button should be last in hierarchy
Here is my output
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.
add a comment |
Please check below image make sure your Views hierarchy as followed your button should be last in hierarchy
Here is my output
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.
add a comment |
Please check below image make sure your Views hierarchy as followed your button should be last in hierarchy
Here is my output
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.
Please check below image make sure your Views hierarchy as followed your button should be last in hierarchy
Here is my output
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.
edited Nov 24 '18 at 4:11
answered Nov 23 '18 at 12:00
Khush
1188
1188
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 23 '18 at 4:33
Alex Bailey
370316
370316
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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