英文:
Why doesn't cornerRadius work by SwiftUI?
问题
我指定了clipShape,并且仅使用SwiftUI的cornerRadius(20)来处理图像。它确实裁剪了图像,但不正确。为什么?
Image("sample_image")
.resizable()
.scaledToFit()
.frame(height: UIScreen.main.bounds.width)
.clipShape(RoundedRectangle(cornerRadius: 50))
我该如何修复它?
英文:
I designated the clipShape and just cornerRadius(20) for the image by SwiftUI.
It did clip the image. But it did not correctly. Why?
Image("sample_image")
.resizable()
.scaledToFit()
.frame(height: UIScreen.main.bounds.width)
.clipShape(RoundedRectangle(cornerRadius: 50))
How should I fix it?
答案1
得分: 1
尝试使用.cornerRadius而不是.clipShape
AsyncImage(url: URL(string: imageUrl)) { image in
image
.resizable()
.scaledToFit()
.frame(height: UIScreen.main.bounds.width)
.cornerRadius(50)
}
希望这有所帮助 ![]()
英文:
Try using .cornerRadius instead of .clipShape
AsyncImage(url: URL(string:imageUrl)) { image in
image
.resizable()
.scaledToFit()
.frame(height: UIScreen.main.bounds.width)
.cornerRadius(50)
}
I hope this helps ![]()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论