- This is very simple and light photo browser written swift. and also you can show images or videos.
To run the example project, clone the repo, and run pod install
from the Example directory first.
CSPhotoGallery is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "CSPhotoGallery"
First Step - import CSPhotoGallery
to your project
Second Step - Add a delegate CGPhotoGalleryDelegate
to your class & add a delegate methods
func getAssets(assets: [PHAsset]) {
// if you implement this delegate function, you will receive assets
// Example )
assets.forEach { asset in
let size = CGSize(width: asset.pixelWidth, height: asset.pixelHeight)
PhotoManager.sharedInstance.assetToImage(asset: asset, imageSize: size, completionHandler: { image in
// Do something
})
}
}
Third Step - Present a CSPhotoGalleryViewController
let vc = CSPhotoGalleryViewController.instance
vc.delegate = self
vc.CHECK_MAX_COUNT = 20
vc.horizontalCount = 3
vc.mediaType = .image // or .video
present(vc, animated: true)
And you can customize ui design
public class CSPhotoDesignManager {
public static var instance: CSPhotoDesignManager = CSPhotoDesignManager()
// Photo collection view
public var photoGalleryBackButtonImage: UIImage?
// Photo detail view
public var photoDetailBackButtonImage: UIImage?
// OK Button Title
public var photoGalleryOKButtonTitle: String?
// Check Image
public var photoGalleryCheckImage: UIImage?
// UnCheck Image
public var photoGalleryUnCheckImage: UIImage?
// When OK Button is hidden, CheckCountLabel and CheckBtn is hidden
public var isOKButtonHidden = false
}
chansim.youk, dbrckstla@naver.com
CSPhotoGallery is available under the MIT license. See the LICENSE file for more info.