|
Hi to all, I'm trying to solve the challenges in project 6 https://www.hackingwithswift.com/read/6/6/wrap-up The first was quite easy (Try replacing the widthAnchor of our labels with leadingAnchor and trailingAnchor constraints, which more explicitly pin the label to the edges of its parent.) I'm not sure to understand what "try using the safeAreaLayoutGuide for those constraints" means The third challeng is really hard: Try making the height of your labels equal to 1/5th of the main view, minus 10 for the spacing. After half an hour of obscure coding I've read the hint, so I tried label.heightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.heightAnchor, multiplier: 0.5, constant: 10) but the results is not what I expected to be... Any hint? |
|
|
|
SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community! Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
I think he wants you to use the |
|
Thanks for your answers but changing that value doesn't change anything, visually talking... I'm sure that I miss something but I really can't understand what's the problem... I think I'll try to follow again the entire project videos... |
|
I just did that exercise half an hour ago and had the same problem as you. After trying all kinds of combinations, I finally thought about what the constant is actually supposed to do... It adds space to your view. That is the opposite of what we want. We want to delete 10 points from the label and use that space for the white space between the labels. So... instead of constant: 10 we have to use constant: -10. |
|
Hi All I think I solved challenge 1 and 2 as well from this project from what I understood goes like this: Whe you guys will rotoate your device or / simulator than that label will not be streched fully on the whole screen, "so the label is pushed away from the top and bottom of the safe area, so it doesn’t sit under the notch". Hope it helps! Note: If you guys don't add "safeAreaLayoutGuide" to these constraits the labels will be still streched out fully on the screen this is in challenge 1.
// label.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true -> this is the previous line what I've replaced
|
|
label.heightAnchor.constraint(equalToConstant: view.frame.height/5).isActive = true i just did this, but i dont know how to make it autoresize when its horizontal view. |
|
The solution for all 3 challenges:
|
|
Thanks for sharing amazing information keep posting. sjolingbogren.se Thank you for such an amazing discussion. |
SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.