13 questions
0
votes
3
answers
96
views
Alignment across different VStacks and HStacks
I would like achieve the following:
HCenter align blue and green boxes
Leading align red and purple boxes
Top align blue and red boxes
VCenter align green and purple boxes
The following SwiftUI ...
1
vote
2
answers
124
views
In SwiftUI, what's the best way to anchor one view to the containers center, while anchoring an additional view to its edge? [closed]
I'm newish to SwiftUI and trying to understand how I can keep one view horizontally centered on the device screen, while anchoring an additional view to its trailing edge (without uncentering the ...
0
votes
2
answers
144
views
How to set HStack child alignment different
I have HStack with two views: Image and Text. I would like to align Image top but the text center on VerticalAlignment. However, specifying alignment .center for the Text does not do the trick , it is ...
0
votes
2
answers
309
views
How to align two elements in different views with leading edge in SwiftUI?
I have this custom cell. I have tried different approach to align "Skill Range" and "Time" by adding .alignmentGuide(.leading) to both "Skill Range" and "Time" ...
1
vote
1
answer
175
views
Custom alignment guide in Form
I want to create a SwiftUI Form with lines that have a key Text, a colon and a value Text. I want all the keys to be leading-aligned and all the values to be leading-aligned, like in this picture. Is ...
1
vote
2
answers
2k
views
how to use custom alignmentGuide in ZStack
I want to use alignmentGuide to align center a Text view in ZStack to implement view as bellow, blue block is align traling, Text "abc" and "123" is align center of view.
My code ...
2
votes
1
answer
588
views
Aligning views across stacks when nested (within a overlay, background, or ZStack)
A typical problem in SwiftUI is aligning two texts with their baselines in different VStacks, when the content of these VStacks differs in height.
Apple has a nice article on how to solve this problem ...
1
vote
1
answer
628
views
SwiftUI VStack alignment guide with other views
I'm struggling to achieve the following custom alignment in a SwiftUI VStack:
I've created a custom alignment guide to use in the Event view, as follows:
extension HorizontalAlignment {
struct ...
1
vote
1
answer
148
views
swiftui Alignment Guide for two view
I have two Rectangles, Rectangle A and Rectangle B. Rectangle A will move horizontally, and the center point of A will align with the top left corner of B in the horizontal direction. B will rotate ...
1
vote
1
answer
183
views
How to use alignment guides in swift ui
Simply what I'm trying to achieve is this
The Circle aligned to the bottom left edge of the other image
I know that alignment guides should be used in this scenario, but I truly can't understand the ...
0
votes
1
answer
123
views
firstTextBsaeline alignment not working in LazyHStack
I'm trying to align the first line of texts with .firstTextBaseline however doesn't seem to work with LazyHStack. Similarly using AlignmentGuide also doesn't seem to be working. Am i missing something ...
2
votes
1
answer
494
views
SwiftUI center align a view except if another view "pushes" it up
Here is a breakdown.
I have a zstack that contains 2 vstacks.
first vstack has a spacer and an image
second has a text and button.
ZStack {
VStack {
Spacer()
Image("some image&...
3
votes
2
answers
540
views
How to align two UILabels on the Y axis of the center of the first line of text
please see the image below for two examples of what is to be achived
the alignment should be on the Center Y of the first lines of each UILabels and should work regardless of font size or font. ...