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

Photo Gallery

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

A masonry photo gallery with a +count tile.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

PhotoGallery.swift
// Photo Gallery · syxUI · https://syxui.dev/components/media2-gallery
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

// Photo gallery masonry
struct PhotoGallery: View {
    var body: some View {
        HStack(spacing: 6) {
            VStack(spacing: 6) {
                Image("photo_travel").resizable().scaledToFill().frame(width: 140, height: 160).clipped()
                Image("photo_food").resizable().scaledToFill().frame(width: 140, height: 100).clipped()
            }
            VStack(spacing: 6) {
                Image("photo_pet").resizable().scaledToFill().frame(width: 100, height: 110).clipped()
                Image("photo_product").resizable().scaledToFill().frame(width: 100, height: 150).clipped().overlay(alignment: .bottomTrailing) { ZStack { Color.black.opacity(0.4); Text("+8").font(.system(size: 16, weight: .bold)).foregroundStyle(.white) } }
            }
        }.frame(width: 252).clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
    }
}
iOS 17 · 4 dependencies

Dependencies

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

Requires iOS 17