Reputation: 59
I am new to swiftUI and I have been trying to place images in a Rounded rectangle but every time I use scaledToFill()
The corners of the rectangle disappear.
This is my code :
Image("img_6").resizable()
.scaledToFill()
.clipShape(RoundedRectangle(cornerRadius: 55,
style: .continuous))
.shadow(radius: 9)
.frame(height: 550).clipped()
Upvotes: 1
Views: 909
Reputation: 257719
Modifiers order is important. In your case just move .clipShape
after .frame
, as
tall:
wide:
Color.clear
.frame(height: 550)
.overlay(Image("img")
.resizable()
.scaledToFill())
.clipShape(RoundedRectangle(cornerRadius: 55,
style: .continuous))
.shadow(radius: 9)
Note: .clipped
not needed, because .clipShape
already performs clipping
Upvotes: 3