IG
Size: a a a
IG
OL
HStack(alignment: .center){
Text("1")
Spacer()
HStack {
Text("A really long name that person").lineLimit(1).frame(maxWidth: .infinity, alignment: .trailing)
Text("0:0")
.foregroundColor(.blue)
Text("Another one of those long text").lineLimit(1).frame(maxWidth: .infinity, alignment: .leading)
}
Spacer()
Image(systemName: "heart")
}.padding()
IG
n
IG
alignmentGuide
𝕬
Text("A really long name that person")
Text("0 : 0")
.layoutPriority(1)
.alignmentGuide(HorizontalAlignment.center) { d in d.width / 2 }
Text("Another one of those long text")
IG
G
n
G
𝕬
n
𝕬
VC
n
ІЛ
𝕬
D
PV
IG
HorizontalAlignment {
private
enum HCenterAlignment: AlignmentID {
static
func defaultValue(in dimensions: ViewDimensions) -> CGFloat {
return dimensions[HorizontalAlignment.center]
}
}
static
let hCenterred = HorizontalAlignment(HCenterAlignment.
self)
}
struct ContentView: View {
var body:
some View {
HStack(alignment:.center) {
Text("1")
Text("A really long name that person")
Text("0 : 0")
.layoutPriority(10)
.alignmentGuide(.hCenterred, computeValue: { $0.width / 2.0 })
Text("Another one of those long text")
Text("SMILE").layoutPriority(1)
}
.frame( alignment: Alignment(horizontal: .hCenterred, vertical: .center))
.lineLimit(1)
}
}
```