-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stick to the safe area when rendering test app #1512
Conversation
tv.translatesAutoresizingMaskIntoConstraints = false | ||
|
||
self.view.addSubview(tv) | ||
let safeGuide = self.view.safeAreaLayoutGuide |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think instead of all of this, you could maybe just do
tv.bounds = view.safeAreaLayoutGuide.layoutFrame
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sweet. Will try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this works, it's worth pointing out that it's a bit backwards/unconventional--a UIView
's bounds
rect is expressed relative to the view's own coordinate system, whereas its frame
rect is expressed relative to its superview
's coordinate system. It's more typical to declare mySubview.frame = mySuperview.bounds
, to get mySubview
to fill mySuperview
's rect.
In this case, view.safeAreaLayoutGuide.layoutFrame
is expressed view
's coordinate system, not tv
's.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to merge as-is. Hopefully soon we'll have a scaffolding-like composable in this app which gets us a traditional top/nav bar on Android and iOS (and will allow drawing edge-to-edge again).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know--it was worth a shot. Definitely safe to merge as is!
Did I do any of this right? It looks right...