如何在 SwiftUI 中将图像粘贴到屏幕的右上角

问题描述 投票:0回答:1

image of my problem and code along with it

所以我正在寻找如何将此图像粘贴到屏幕的右上角。我应该使用几何阅读器吗?如果是的话,我将如何在我的代码中实现它。

Image("OnBoardingBackground")
            
            VStack {
                Image("SignInImage")
                    .resizable()
                    .scaledToFit()
                
                Text("Get Started")
                    .font(.largeTitle)
                    .fontWeight(.heavy)
                    .fontWidth(.expanded)
                    .fontDesign(.monospaced)
                
                Spacer()
                
                Text("Find community within your community")
                    .font(.subheadline)
                    .fontWeight(.heavy)
                    .fontWidth(.standard)
                    .multilineTextAlignment(.center)
                    .fontDesign(.monospaced)
                    .frame(width: 200)

                
                Divider()

这只是我所拥有的一小部分。

我已经多次尝试几何阅读器,但似乎无法让它正常工作。老实说,不知道还能尝试什么。

抱歉,如果有一个简单的解决方案,我似乎找不到一个,而且我对 swiftui 还比较陌生。

ios swift xcode swiftui
1个回答
0
投票

将图像粘贴到右上角:

您需要更换:

Image("OnBoardingBackground")

至:

VStack {
   HStack {
       Spacer(minLength: 0)

       Image("OnBoardingBackground")
   }

   Spacer(minLength: 0)
}
© www.soinside.com 2019 - 2024. All rights reserved.