|
@@ -10,8 +10,11 @@ import UIKit
|
|
|
|
|
|
class BrowsePicturesViewController: BaseViewController {
|
|
|
|
|
|
+ //存储图片Str数组
|
|
|
+ var imageStrs:[String]
|
|
|
+
|
|
|
//存储图片数组
|
|
|
- var images:[String]
|
|
|
+ var images:[UIImage]
|
|
|
|
|
|
//默认显示的图片索引
|
|
|
var index:Int
|
|
@@ -26,7 +29,8 @@ class BrowsePicturesViewController: BaseViewController {
|
|
|
var pageControl : UIPageControl!
|
|
|
|
|
|
//初始化
|
|
|
- init(images:[String], index:Int = 0){
|
|
|
+ init(imageStrs:Array<String> = [],images:Array<UIImage> = [], index:Int = 0){
|
|
|
+ self.imageStrs = imageStrs
|
|
|
self.images = images
|
|
|
self.index = index
|
|
|
|
|
@@ -84,7 +88,22 @@ class BrowsePicturesViewController: BaseViewController {
|
|
|
pageControl = UIPageControl()
|
|
|
pageControl.center = CGPoint(x: UIScreen.main.bounds.width/2,
|
|
|
y: UIScreen.main.bounds.height - 20 - kSafeTabBarHeight)
|
|
|
- pageControl.numberOfPages = images.count
|
|
|
+ if !(imageStrs.isEmpty ){
|
|
|
+ pageControl.numberOfPages = imageStrs.count
|
|
|
+ if imageStrs.count == 1 {
|
|
|
+ pageControl.isHidden = true
|
|
|
+ }else {
|
|
|
+ pageControl.isHidden = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if !(images.isEmpty ){
|
|
|
+ pageControl.numberOfPages = images.count
|
|
|
+ if images.count == 1 {
|
|
|
+ pageControl.isHidden = true
|
|
|
+ }else {
|
|
|
+ pageControl.isHidden = true
|
|
|
+ }
|
|
|
+ }
|
|
|
pageControl.isUserInteractionEnabled = false
|
|
|
pageControl.currentPage = index
|
|
|
view.addSubview(self.pageControl)
|
|
@@ -132,14 +151,25 @@ UICollectionViewDelegateFlowLayout{
|
|
|
cellForItemAt indexPath: IndexPath)
|
|
|
-> UICollectionViewCell {
|
|
|
let cell = BrowsePicturesPagerViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
|
|
|
- cell.iconImageView.kf.setImage(with: kURLImage(name: images[indexPath.row]), placeholder: kImage(name: ""))
|
|
|
+ if !(imageStrs.isEmpty){
|
|
|
+ cell.iconImageView.kf.setImage(with: kURLImage(name: imageStrs[indexPath.row]), placeholder: kImage(name: ""))
|
|
|
+ }
|
|
|
+ if !(images.isEmpty){
|
|
|
+ cell.iconImageView.image = images[indexPath.row]
|
|
|
+ }
|
|
|
return cell
|
|
|
}
|
|
|
|
|
|
//collectionView单元格数量
|
|
|
func collectionView(_ collectionView: UICollectionView,
|
|
|
numberOfItemsInSection section: Int) -> Int {
|
|
|
- return self.images.count
|
|
|
+ if !(imageStrs.isEmpty){
|
|
|
+ return self.imageStrs.count
|
|
|
+ }
|
|
|
+ if !(images.isEmpty){
|
|
|
+ return self.images.count
|
|
|
+ }
|
|
|
+ return 0
|
|
|
}
|
|
|
|
|
|
//collectionView单元格尺寸
|