MomentsGallery 是一个受 Twitter Moments 启发的画廊视图控制器。在翻动照片时具有视差效果,可点击查看全图,并具有添加标题和副标题的功能。
要运行示例项目,请克隆仓库,并首先从示例目录运行 pod install
。
var images = ["1.jpg", "2.jpg", "3.jpg"]
var moments: [Moment] = []
for imagePath in images {
let moment = Moment(image: UIImage(named: imagePath))
moments.append(moment)
}
let momentsVC = MomentsGallery(moments: moments)
self.presentViewController(momentsVC, animated: true, completion: nil)
var images = ["http://url.com/1.jpg", "http://url.com/2.jpg", "http://url.com/3.jpg"]
var moments: [Moment] = []
for imageUrl in images {
let moment = Moment(url: imageUrl)
moments.append(moment)
}
let momentsVC = MomentsGallery(moments: moments)
self.presentViewController(momentsVC, animated: true, completion: nil)
let momentsVC = MomentsGallery(moments: [moment, moment, moment])
momentsVC.initialPageIndex = 2 // Set initial index before presenting, not animated
self.presentViewController(momentsVC, animated: true, completion: nil)
momentsVC.scrollToIndex(2) // Set index after view controller is presented, animated
MomentsGallery 可通过 CocoaPods 安装。要安装,请简单地在 Podfile 中添加以下行
pod "MomentsGallery"
Melvin Beemer, [email protected]
MomentsGallery 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。