CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Dec 2017 |
| SwiftSwift Version | 4.0 |
| SPMSupports SPM | ✓ |
Maintained by Luan Tran.
Custom CollectionView like as Facebook Feed for iOS
|
|
|---|
To integrate PhotoCollectionView into your Xcode project using CocoaPods, specify it in your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'PhotoCollectionView', '~> 1.4.2' Then, run the following command:
$ pod installSources folder into your projectUse can create instance of PhotoCollectionView by code:
import PhotoCollectionView
let photoCollectionView = PhotoCollectionView(frame: CGRect(x: 0, y: 0, width: 320, height: 240))
or create an UIView in storyboard and Outlet it
|
|---|
import PhotoCollectionView
@IBOutlet weak var imageCollectionView: PhotoCollectionView!
PhotoCollectionViewDataSource for binding dataextension ViewController: PhotoCollectionViewDataSource {
func numPhotos(in photoCollectionView: PhotoCollectionView) -> Int {
// Return count photo.
return 10
}
// You can use image for data
func photoColletionView(_ photoCollectionView: PhotoCollectionView, imageAt index: Int) -> UIImage? {
// return image need to show.
return UIImage(named: "image\(index + 1)")
}
// or use image url
func photoCollectionView(_ photoCollectionView: PhotoCollectionView, urlImageAt index: Int) -> URL? {
return URL(string: *your image URL here*)
}
}
dataSource of PhotoCollectionViewimageCollectionView.dataSource = self
Handle image selection in PhotoCollectionView
imageCollectionView.delegate = self
extension ViewController: PhotoCollectionViewDelegate {
func photoCollectionView(_ photoCollectionView: PhotoCollectionView, didSelectImageAt index: Int) {
print("Press at index \(index)")
}
}
Luan Tran - [email protected]