You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
API Reference
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
Simple Usage
Just pass these three parameters for a basic setup:
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
That’s all you need to get started!
structContentView:View{@StateprivatevarisVisible:Bool=false@StateprivatevaractiveIndex=0letimageUrls:[String]=["url1","url2"....."url100"]varbody:someView{VStack{
// your code logic here
}.frame(maxWidth:.infinity, maxHeight:.infinity).photoBoxKit(activeIndex: $activeIndex, isVisible: $isVisible, urls: imageUrls)}}
Custom PhotoBox
structContentView:View{@StateprivatevarisVisible:Bool=false@StateprivatevaractiveIndex=0letimageUrls:[String]=["url1","url2"....."url100"]varbody:someView{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
)}}
Demo 📸
About
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.