HomeiOS Developmentios - Heart swiftUI view in HStack and align accent view to...

ios – Heart swiftUI view in HStack and align accent view to first baseline textual content


I wish to accomplish two issues. First, id wish to align the “Swift View” to be within the heart. Second, id wish to align the view to the best to firstTextBaseline of the primary view (Textual content).

Im unsure what the easiest way to do that is, however ive discovered a number of comparable postings, however I cant determine methods to get it to appear to be this:

closing desired look

My present code appears like this however I dont prefer it:

struct ContentView: View {
    var physique: some View {
      VStack(alignment: .subCentre) {
        HStack(alignment: .firstTextBaseline) {
            Textual content("Swift View")
              .foregroundColor(.white)
              .font(.largeTitle)
              .padding(35)
              .background(
                LinearGradient(
                  colours: [.orange, .red],
                  startPoint: .topLeading,
                  endPoint: .bottomTrailing
                )
              )
              .cornerRadius(20)
              .alignmentGuide(.subCentre) { d in d.width/2 }
          Textual content("take a look at")
        }
        //Geometry reader robotically fills the father or mother
        //that is aligned with the customized information
        GeometryReader { geometry in
            EmptyView()
        }
        .alignmentGuide(.subCentre) { d in d.width/2 }
      }
    }
}

Any options?

Including a GeometryReady on the backside appears janky. Cant be the easiest way to do issues.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments