How to make an Image circular in swiftUI

SwiftUI provides modifiers to add a clip shape o your views like image etc. We can use modifier named .clipShape(Circle()) , which makes the image circular in SwiftUI.

Image("your_image_name") // Replace with your image name
            .resizable()
            .aspectRatio(contentMode: .fill)
            .frame(width: 150, height: 150) // Adjust the size as needed
            .clipShape(Circle()) // Makes the image circular

Modfiers used to make Image circular in Swift

  • .resizable(): Makes the image scalable.
  • .aspectRatio(contentMode: .fill): Ensures the image fills the circular frame.
  • .frame(width:200, height:200): Defines the size of the image.
  • .clipShape(Circle()): Clips the image into a circle.