Add a border with cornerRadius to an Image in SwiftUI Xcode beta 5

SwiftUI 1.0

Using cornerRadius & overlay Modifiers

Here is another way in which we can use a cornerRadius modifier (which clips the view) and then overlay a stroke with a color.

VStack(spacing: 40) {
    Text("Image Border").font(.largeTitle)
    Text("Using cornerRadius & overlay").font(.title).foregroundColor(.gray)
    Text("Using cornerRadius will also clip the image. Then overlay a border.")
        .frame(minWidth: 0, maxWidth: .infinity)

        .overlay(RoundedRectangle(cornerRadius: 10)
            .stroke(, lineWidth: 4))
        .shadow(radius: 10)


enter image description here

Leave a Comment