|
In Project6 we make a copy of Project2 (The "Guess the Flag" app) and add new constraints to the buttons in order to make them fit on the screen even when the device is rotated to landscape mode. I followed the instructions, and it makes the flags fit on the screen, but the borders around each button do not resize properly along with the flags after the device is rotated. I can still see the borders on each flag, but they are not around the edges. On the first button, the border is inset on all sides. On the second 2 buttons the borders are inset vertically, but not horizontally. Does anybody know how to fix this? We have only been taught to add the borders by adding code like this in our
So, I don't know of any way to modify them after the device orientation changes and the buttons are resized. |
|
|
|
|
|
If someone still experiences this issue please post a pic :) by checking the possibilities it might be the gray color mixes with flag borders making it seem as insetted or offsetted by small bit. Try to make the border thicker e.g. borderWidth = 2 Also if this is not the issue try to add ->
inside viewDidLoad() setNeedsLayout() - this method informs the system that the current layout is invalid and it should be updated in the next drawing cycle. layoutIfNeeded() - this method asks the system to update the layout. I have the same part of the code as posted above and it works fine. There are tiny insets visible in simulagtor but I suspect it is just how the color mixes with flag :) |
|
|
|
|
|
Thanks |
|
When button2.height = button1.height and button3.height = button2.height is not set
button1 and button2 border is correctly positioned but button3 border are inside the flag.
closest I reached to the soln: without height constraints
When button2.height = button1.height and button3.height = button2.height is set
button1, button2, button3 borders are inside the flag.
tutorial preview: with height constraints
borderWidth = 2
and inside viewDidLoad(): |
|
Finally found the Solution:
NOTE: if you have not changed the type then you will see all blue flags |
SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until February 9th.
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.