Sam*_*Sam 0 image uiimageview swift swiftui
我需要以仅显示图像顶部的方式对齐 a\xc2\xa0UIImageView\xc2\xa0 。
\n原始图片:-
\n我从下面的代码中获得了图像:-
\n代码:-
\nImage("ImageDemo")\n .resizable()\n .scaledToFill()\n .frame(height: 120, alignment: .center)\n .clipped()\n .cornerRadius(20, corners: [.topLeft, .topRight])\n .padding(.bottom)\n
Run Code Online (Sandbox Code Playgroud)\n有人可以向我解释如何仅显示顶部部分的图像吗?我已经尝试通过上面的方法实现,但还没有结果。
\n任何帮助将不胜感激。
\n提前致谢。
\n使用alignment: .top
它可以解决您的问题。
struct ContentView: View {
var body: some View {
Image("Your Image Here!")
.resizable()
.scaledToFill()
.cornerRadius(20)
.frame(height: 120, alignment: .top) // <<: Here
.clipped()
.padding()
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1971 次 |
最近记录: |