How to get height of tabBar on iPhone X











up vote
-3
down vote

favorite












I add ViewController above the tabBar like this



 cardViewController = storyboard?.instantiateViewController(withIdentifier: "CardViewController") as? CardViewController
addChildViewController(cardViewController)
cardViewController.didMove(toParentViewController: self)

view.addSubview(cardViewController.view)

cardViewController.view.frame = CGRect(x: 0, y: view.frame.height - cardHandlAreaHight - tabBarHight,
width: view.bounds.width, height: cardHight)

cardViewController.view.clipsToBounds = true


the size of tabBar i get like this:



tabBarHight = tabBarController?.tabBar.frame.size.height


This is works for all iPhones but not for iPhone X
how to fix this moment ?



enter image description here










share|improve this question
























  • Have you tried constraints?
    – Vyacheslav
    Nov 11 at 10:52










  • Why do you want the height of it anyway?
    – Ümañg ßürmån
    Nov 11 at 10:52










  • @Vyacheslav no. This is Card View, aka bottom sheet this view will animating.
    – Vladimir Pchelyakov
    Nov 11 at 11:07















up vote
-3
down vote

favorite












I add ViewController above the tabBar like this



 cardViewController = storyboard?.instantiateViewController(withIdentifier: "CardViewController") as? CardViewController
addChildViewController(cardViewController)
cardViewController.didMove(toParentViewController: self)

view.addSubview(cardViewController.view)

cardViewController.view.frame = CGRect(x: 0, y: view.frame.height - cardHandlAreaHight - tabBarHight,
width: view.bounds.width, height: cardHight)

cardViewController.view.clipsToBounds = true


the size of tabBar i get like this:



tabBarHight = tabBarController?.tabBar.frame.size.height


This is works for all iPhones but not for iPhone X
how to fix this moment ?



enter image description here










share|improve this question
























  • Have you tried constraints?
    – Vyacheslav
    Nov 11 at 10:52










  • Why do you want the height of it anyway?
    – Ümañg ßürmån
    Nov 11 at 10:52










  • @Vyacheslav no. This is Card View, aka bottom sheet this view will animating.
    – Vladimir Pchelyakov
    Nov 11 at 11:07













up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











I add ViewController above the tabBar like this



 cardViewController = storyboard?.instantiateViewController(withIdentifier: "CardViewController") as? CardViewController
addChildViewController(cardViewController)
cardViewController.didMove(toParentViewController: self)

view.addSubview(cardViewController.view)

cardViewController.view.frame = CGRect(x: 0, y: view.frame.height - cardHandlAreaHight - tabBarHight,
width: view.bounds.width, height: cardHight)

cardViewController.view.clipsToBounds = true


the size of tabBar i get like this:



tabBarHight = tabBarController?.tabBar.frame.size.height


This is works for all iPhones but not for iPhone X
how to fix this moment ?



enter image description here










share|improve this question















I add ViewController above the tabBar like this



 cardViewController = storyboard?.instantiateViewController(withIdentifier: "CardViewController") as? CardViewController
addChildViewController(cardViewController)
cardViewController.didMove(toParentViewController: self)

view.addSubview(cardViewController.view)

cardViewController.view.frame = CGRect(x: 0, y: view.frame.height - cardHandlAreaHight - tabBarHight,
width: view.bounds.width, height: cardHight)

cardViewController.view.clipsToBounds = true


the size of tabBar i get like this:



tabBarHight = tabBarController?.tabBar.frame.size.height


This is works for all iPhones but not for iPhone X
how to fix this moment ?



enter image description here







ios swift






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 11:09









Kamran

5,17811027




5,17811027










asked Nov 11 at 10:49









Vladimir Pchelyakov

1818




1818












  • Have you tried constraints?
    – Vyacheslav
    Nov 11 at 10:52










  • Why do you want the height of it anyway?
    – Ümañg ßürmån
    Nov 11 at 10:52










  • @Vyacheslav no. This is Card View, aka bottom sheet this view will animating.
    – Vladimir Pchelyakov
    Nov 11 at 11:07


















  • Have you tried constraints?
    – Vyacheslav
    Nov 11 at 10:52










  • Why do you want the height of it anyway?
    – Ümañg ßürmån
    Nov 11 at 10:52










  • @Vyacheslav no. This is Card View, aka bottom sheet this view will animating.
    – Vladimir Pchelyakov
    Nov 11 at 11:07
















Have you tried constraints?
– Vyacheslav
Nov 11 at 10:52




Have you tried constraints?
– Vyacheslav
Nov 11 at 10:52












Why do you want the height of it anyway?
– Ümañg ßürmån
Nov 11 at 10:52




Why do you want the height of it anyway?
– Ümañg ßürmån
Nov 11 at 10:52












@Vyacheslav no. This is Card View, aka bottom sheet this view will animating.
– Vladimir Pchelyakov
Nov 11 at 11:07




@Vyacheslav no. This is Card View, aka bottom sheet this view will animating.
– Vladimir Pchelyakov
Nov 11 at 11:07












1 Answer
1






active

oldest

votes

















up vote
1
down vote













You should position the added view via Auto Layout, instead of setting the frame.



But if you really need to work with pixel sizes, you can access to bottom padding via



view.safeAreaInsets.bottom


You should also have a look at: https://stackoverflow.com/a/46831519/2133377






share|improve this answer





















  • can you give an example how to add ViewController via Auto Layout? And how Can i use view.safeAreaInsets.bottom in my case? set Y at view.safeAreaInsets.bottom
    – Vladimir Pchelyakov
    Nov 11 at 13:38












  • For Auto Layout have a look at: developer.apple.com/library/archive/documentation/… For the solution with view.safeAreaInsets.bottom. you have to replace tabBarHight with view.safeAreaInsets.bottom
    – messeb
    Nov 11 at 22:16










  • this will be works only in viewDidLayoutSubviews(), but I need this value in moment of ViewDidLoad.
    – Vladimir Pchelyakov
    Nov 12 at 8:33










  • Answer don't solve my problem, I need to know this value at the viewDidLoad. Have you any Ideas?
    – Vladimir Pchelyakov
    Nov 24 at 8:50










  • But viewDidLoad() is the wrong place to determine the size of views. Therefore you should use Auto Layout or place the calculation in viewDidLayoutSubviews().
    – messeb
    Nov 25 at 12:28











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',
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%2f53247982%2fhow-to-get-height-of-tabbar-on-iphone-x%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













You should position the added view via Auto Layout, instead of setting the frame.



But if you really need to work with pixel sizes, you can access to bottom padding via



view.safeAreaInsets.bottom


You should also have a look at: https://stackoverflow.com/a/46831519/2133377






share|improve this answer





















  • can you give an example how to add ViewController via Auto Layout? And how Can i use view.safeAreaInsets.bottom in my case? set Y at view.safeAreaInsets.bottom
    – Vladimir Pchelyakov
    Nov 11 at 13:38












  • For Auto Layout have a look at: developer.apple.com/library/archive/documentation/… For the solution with view.safeAreaInsets.bottom. you have to replace tabBarHight with view.safeAreaInsets.bottom
    – messeb
    Nov 11 at 22:16










  • this will be works only in viewDidLayoutSubviews(), but I need this value in moment of ViewDidLoad.
    – Vladimir Pchelyakov
    Nov 12 at 8:33










  • Answer don't solve my problem, I need to know this value at the viewDidLoad. Have you any Ideas?
    – Vladimir Pchelyakov
    Nov 24 at 8:50










  • But viewDidLoad() is the wrong place to determine the size of views. Therefore you should use Auto Layout or place the calculation in viewDidLayoutSubviews().
    – messeb
    Nov 25 at 12:28















up vote
1
down vote













You should position the added view via Auto Layout, instead of setting the frame.



But if you really need to work with pixel sizes, you can access to bottom padding via



view.safeAreaInsets.bottom


You should also have a look at: https://stackoverflow.com/a/46831519/2133377






share|improve this answer





















  • can you give an example how to add ViewController via Auto Layout? And how Can i use view.safeAreaInsets.bottom in my case? set Y at view.safeAreaInsets.bottom
    – Vladimir Pchelyakov
    Nov 11 at 13:38












  • For Auto Layout have a look at: developer.apple.com/library/archive/documentation/… For the solution with view.safeAreaInsets.bottom. you have to replace tabBarHight with view.safeAreaInsets.bottom
    – messeb
    Nov 11 at 22:16










  • this will be works only in viewDidLayoutSubviews(), but I need this value in moment of ViewDidLoad.
    – Vladimir Pchelyakov
    Nov 12 at 8:33










  • Answer don't solve my problem, I need to know this value at the viewDidLoad. Have you any Ideas?
    – Vladimir Pchelyakov
    Nov 24 at 8:50










  • But viewDidLoad() is the wrong place to determine the size of views. Therefore you should use Auto Layout or place the calculation in viewDidLayoutSubviews().
    – messeb
    Nov 25 at 12:28













up vote
1
down vote










up vote
1
down vote









You should position the added view via Auto Layout, instead of setting the frame.



But if you really need to work with pixel sizes, you can access to bottom padding via



view.safeAreaInsets.bottom


You should also have a look at: https://stackoverflow.com/a/46831519/2133377






share|improve this answer












You should position the added view via Auto Layout, instead of setting the frame.



But if you really need to work with pixel sizes, you can access to bottom padding via



view.safeAreaInsets.bottom


You should also have a look at: https://stackoverflow.com/a/46831519/2133377







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 11:56









messeb

17118




17118












  • can you give an example how to add ViewController via Auto Layout? And how Can i use view.safeAreaInsets.bottom in my case? set Y at view.safeAreaInsets.bottom
    – Vladimir Pchelyakov
    Nov 11 at 13:38












  • For Auto Layout have a look at: developer.apple.com/library/archive/documentation/… For the solution with view.safeAreaInsets.bottom. you have to replace tabBarHight with view.safeAreaInsets.bottom
    – messeb
    Nov 11 at 22:16










  • this will be works only in viewDidLayoutSubviews(), but I need this value in moment of ViewDidLoad.
    – Vladimir Pchelyakov
    Nov 12 at 8:33










  • Answer don't solve my problem, I need to know this value at the viewDidLoad. Have you any Ideas?
    – Vladimir Pchelyakov
    Nov 24 at 8:50










  • But viewDidLoad() is the wrong place to determine the size of views. Therefore you should use Auto Layout or place the calculation in viewDidLayoutSubviews().
    – messeb
    Nov 25 at 12:28


















  • can you give an example how to add ViewController via Auto Layout? And how Can i use view.safeAreaInsets.bottom in my case? set Y at view.safeAreaInsets.bottom
    – Vladimir Pchelyakov
    Nov 11 at 13:38












  • For Auto Layout have a look at: developer.apple.com/library/archive/documentation/… For the solution with view.safeAreaInsets.bottom. you have to replace tabBarHight with view.safeAreaInsets.bottom
    – messeb
    Nov 11 at 22:16










  • this will be works only in viewDidLayoutSubviews(), but I need this value in moment of ViewDidLoad.
    – Vladimir Pchelyakov
    Nov 12 at 8:33










  • Answer don't solve my problem, I need to know this value at the viewDidLoad. Have you any Ideas?
    – Vladimir Pchelyakov
    Nov 24 at 8:50










  • But viewDidLoad() is the wrong place to determine the size of views. Therefore you should use Auto Layout or place the calculation in viewDidLayoutSubviews().
    – messeb
    Nov 25 at 12:28
















can you give an example how to add ViewController via Auto Layout? And how Can i use view.safeAreaInsets.bottom in my case? set Y at view.safeAreaInsets.bottom
– Vladimir Pchelyakov
Nov 11 at 13:38






can you give an example how to add ViewController via Auto Layout? And how Can i use view.safeAreaInsets.bottom in my case? set Y at view.safeAreaInsets.bottom
– Vladimir Pchelyakov
Nov 11 at 13:38














For Auto Layout have a look at: developer.apple.com/library/archive/documentation/… For the solution with view.safeAreaInsets.bottom. you have to replace tabBarHight with view.safeAreaInsets.bottom
– messeb
Nov 11 at 22:16




For Auto Layout have a look at: developer.apple.com/library/archive/documentation/… For the solution with view.safeAreaInsets.bottom. you have to replace tabBarHight with view.safeAreaInsets.bottom
– messeb
Nov 11 at 22:16












this will be works only in viewDidLayoutSubviews(), but I need this value in moment of ViewDidLoad.
– Vladimir Pchelyakov
Nov 12 at 8:33




this will be works only in viewDidLayoutSubviews(), but I need this value in moment of ViewDidLoad.
– Vladimir Pchelyakov
Nov 12 at 8:33












Answer don't solve my problem, I need to know this value at the viewDidLoad. Have you any Ideas?
– Vladimir Pchelyakov
Nov 24 at 8:50




Answer don't solve my problem, I need to know this value at the viewDidLoad. Have you any Ideas?
– Vladimir Pchelyakov
Nov 24 at 8:50












But viewDidLoad() is the wrong place to determine the size of views. Therefore you should use Auto Layout or place the calculation in viewDidLayoutSubviews().
– messeb
Nov 25 at 12:28




But viewDidLoad() is the wrong place to determine the size of views. Therefore you should use Auto Layout or place the calculation in viewDidLayoutSubviews().
– messeb
Nov 25 at 12:28


















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%2f53247982%2fhow-to-get-height-of-tabbar-on-iphone-x%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

Bressuire

Vorschmack

Quarantine