Questions tagged [swiftui-alignment-guide]

8 questions
3
votes
2 answers

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. currently we have implemented this with different…
memical
  • 2,353
  • 1
  • 24
  • 36
2
votes
1 answer

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 with a custom alignment guide. However, this…
Mischa
  • 15,816
  • 8
  • 59
  • 117
2
votes
1 answer

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") } VStack { Text("press the…
1
vote
2 answers

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 is as bellow: extension HorizontalAlignment { private enum…
mars
  • 109
  • 5
  • 21
1
vote
1 answer

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 EventLeading: AlignmentID { static func…
AndrewC
  • 401
  • 4
  • 19
1
vote
1 answer

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 around its own center point. I have some code but…
mars
  • 109
  • 5
  • 21
1
vote
1 answer

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 concept, that's what I've done so far. …
user19514005
  • 177
  • 1
  • 7
0
votes
1 answer

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 with understanding…
Wy th
  • 33
  • 5