PhotoBoxKit is a lightweight, Swift-native library designed for seamless photo viewing experiences in SwiftUI. It enables developers to present images with customizable backgrounds, swipe gestures, and smooth transitions. To improve performance and memory efficiency, PhotoBoxKit leverages NSCache for smart image caching and reuse.
Parameter | Type | Description | Default |
---|---|---|---|
activeIndex |
Binding<Int> |
current active undex of image. | N/A |
isVisible |
Binding<Bool> |
show or hide photobox. | N/A |
urls |
[String] |
urls of images. | N/A |
counter |
Bool |
visible or not image counter. | true |
gallery |
Bool |
visible or not bottom gallery. | true |
cornerRadius |
CGFloat |
Corner radius of images. | 0.0 |
bgColor |
Color |
backgorund color. | Color.black.opacity(0.9) |
counterColor |
Color |
color of image counter. | Color.white |
- activeIndex – a state to track the currently selected image
- isVisible – a state to show or hide the photo box
- urls – an array of image URLs
struct ContentView: View {
@State private var isVisible: Bool = false
@State private var activeIndex = 0
let imageUrls: [String] = ["url1", "url2" ..... "url100"]
var body: some View {
VStack {
// your code logic here
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.photoBoxKit(activeIndex: $activeIndex, isVisible: $isVisible, urls: imageUrls)
}
}
struct ContentView: View {
@State private var isVisible: Bool = false
@State private var activeIndex = 0
let imageUrls: [String] = ["url1", "url2" ..... "url100"]
var body: some View {
VStack {
// your code logic here
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.photoBoxKit(
activeIndex: $activeIndex,
isVisible: $isVisible,
urls: imageUrls,
counter: true,
gallery: false,
cornerRadius: 12,
bgColor: .teal,
counterColor: .black
)
}
}