Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import SwiftUI
- /// AvatarView
- /// View protocol - implemented by the custom views.
- struct AvatarView: View {
- /// image
- let image: String
- /// size
- let size: Length
- /// body - default property for the view.
- var body: some View {
- Image(image) // creates an imageview with specified image
- .resizable() // makes image resizable
- .frame(width: size, height: size) // frame for the image (width, height)
- // creates border around the image with 0.5 thikness, and radius size/2 - this will create rounded view outside the image.
- .border(Color.gray.opacity(0.5), width: 0.5, cornerRadius: size/2)
- .cornerRadius(size/2) // This will hide the cutting portion outside the rounded view border - this is required as per the documentation.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement