Skip to content
Photo Album preview
Rendered from the SwiftUI source on this page.

Photo Album

From syxUI — written for both platforms, not translated between them.

Multiple photos sent as a tidy 2×2 grid with a +count overlay.

Chat · SwiftUI · iOS 17

  • chat
  • swiftui

The actual source

ChatPhotoGrid.swift
// Photo Album · syxUI · https://syxui.dev/components/chat-photo-grid
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

// Photo album grid message
struct ChatPhotoGrid: View {
    let imgs = ["photo_food", "photo_travel", "photo_pet", "photo_product"]
    var body: some View {
        HStack {
            Spacer(minLength: 60)
            LazyVGrid(columns: [GridItem(.fixed(96), spacing: 3), GridItem(.fixed(96), spacing: 3)], spacing: 3) {
                ForEach(Array(imgs.enumerated()), id: \.offset) { i, n in
                    Image(n).resizable().scaledToFill().frame(width: 96, height: 96).clipped()
                        .overlay {
                            if i == 3 {
                                ZStack {
                                    Color.black.opacity(0.4)
                                    Text("+5").font(.system(size: 18, weight: .bold)).foregroundStyle(.white)
                                }
                            }
                        }
                }
            }
            .clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous))
        }
    }
}
iOS 17 · 4 dependencies

Dependencies

SwiftUI
  • photo_food (image asset)
  • photo_travel (image asset)
  • photo_pet (image asset)
  • photo_product (image asset)

Requires iOS 17