Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. /// AvatarOverlay
  2. struct AvatarOverlay: View {
  3.  
  4. /// image
  5. let image: String
  6.  
  7. /// gradient colors
  8. let colors: [Color] = [Color.gray.opacity(0.5), Color.gray.opacity(0)]
  9.  
  10. /// gradient
  11. var gradient: LinearGradient {
  12. LinearGradient(gradient: Gradient(colors: colors),
  13. startPoint: .topLeading, endPoint: .center)
  14. }
  15.  
  16. /// body
  17. var body: some View {
  18.  
  19. // ZStack - places views above each other
  20. ZStack(alignment: .topLeading) {
  21.  
  22. // create a rectagular gradient from topleading edge to center edge
  23. Rectangle().fill(gradient).cornerRadius(8)
  24.  
  25. // create avatar image above the gradient
  26. AvatarView(image: image, size: 36)
  27. .padding(.leading, 8)
  28. .padding(.top, 8)
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement