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 ?
ios swift
add a comment |
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 ?
ios swift
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
add a comment |
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 ?
ios swift
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 ?
ios swift
ios swift
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
add a comment |
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
add a comment |
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
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 withview.safeAreaInsets.bottom
. you have to replacetabBarHight
withview.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
add a comment |
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
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 withview.safeAreaInsets.bottom
. you have to replacetabBarHight
withview.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
add a comment |
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
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 withview.safeAreaInsets.bottom
. you have to replacetabBarHight
withview.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
add a comment |
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
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
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 withview.safeAreaInsets.bottom
. you have to replacetabBarHight
withview.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
add a comment |
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 withview.safeAreaInsets.bottom
. you have to replacetabBarHight
withview.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
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%2f53247982%2fhow-to-get-height-of-tabbar-on-iphone-x%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
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