I'm stuck with a problem I'm sure one of you guys can help me with.
I'm developing an iOS
-Application with Swift3
and what I'm trying to create is something like this:
The screenshots show just a part of my UIViewcontroller
. The remaining space is filled with other views that are not part of the question.
As you can see the size and position of my subviews(the icon) depends on the amount of icons i'm given (not more than 8). If more than 5 icons exist it should create a second row and decrease the size of the icons to fit the space. My views should always be centered meaning they are evenly distributd to the left and right.
What i tried so far:
- I created a horizontal
StackView
and tried to fill it programmatically but that did not solve the problem for more than 5 Views. - Tried setting up some views with auto-layout constraints but could not solve the problem of different sizes and positioning.
Of course I could do everything in code. Creating and placing all Views one by one but I would like to find a cleaner solution.
Thanks for you answers. Feedback is appreciated.