|
@@ -25,9 +25,6 @@ class BrowsePicturesViewController: BaseViewController {
|
|
|
//collectionView的布局
|
|
|
var collectionViewLayout: UICollectionViewFlowLayout!
|
|
|
|
|
|
- //页控制器(小圆点)
|
|
|
- var pageControl : UIPageControl!
|
|
|
-
|
|
|
//初始化
|
|
|
init(imageStrs:Array<String> = [],images:Array<UIImage> = [], index:Int = 0){
|
|
|
self.imageStrs = imageStrs
|
|
@@ -51,11 +48,26 @@ class BrowsePicturesViewController: BaseViewController {
|
|
|
return backButton
|
|
|
}()
|
|
|
|
|
|
+ private lazy var pageControl: NXLPageControl = {
|
|
|
+ let pageControl = NXLPageControl()
|
|
|
+ pageControl.pointSize = CGSize.init(width: kScaleValue(value: 4), height: 4)
|
|
|
+ pageControl.currentWidthMultiple = 4//当前点的宽度为其他点的4倍
|
|
|
+ pageControl.localPointSpace = 5
|
|
|
+ pageControl.currentColor = kThemeColor
|
|
|
+ pageControl.otherColor = UIColor(white: 1, alpha: 0.8)
|
|
|
+ pageControl.clickPoint { [weak self] (index) in
|
|
|
+
|
|
|
+ }
|
|
|
+ return pageControl
|
|
|
+ }()
|
|
|
+
|
|
|
//初始化
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
navigationBar.isHidden = true
|
|
|
|
|
|
+ statusBarStyle = .lightContent
|
|
|
+
|
|
|
//背景设为黑色
|
|
|
self.view.backgroundColor = UIColor.black
|
|
|
//collectionView尺寸样式设置
|
|
@@ -79,30 +91,57 @@ class BrowsePicturesViewController: BaseViewController {
|
|
|
self.automaticallyAdjustsScrollViewInsets = false
|
|
|
}
|
|
|
self.view.addSubview(collectionView)
|
|
|
+ self.view.addSubview(pageControl)
|
|
|
|
|
|
//将视图滚动到默认图片上
|
|
|
let indexPath = IndexPath(item: index, section: 0)
|
|
|
collectionView.scrollToItem(at: indexPath, at: .left, animated: false)
|
|
|
|
|
|
- //设置页控制器
|
|
|
- pageControl = UIPageControl()
|
|
|
- pageControl.center = CGPoint(x: UIScreen.main.bounds.width/2,
|
|
|
- y: UIScreen.main.bounds.height - 20 - kSafeTabBarHeight)
|
|
|
if !(imageStrs.isEmpty ){
|
|
|
- pageControl.numberOfPages = imageStrs.count
|
|
|
if imageStrs.count == 1 {
|
|
|
pageControl.isHidden = true
|
|
|
}else {
|
|
|
pageControl.isHidden = true
|
|
|
}
|
|
|
+
|
|
|
+ let pageControlWidth = CGFloat((imageStrs.count - 1) * 10) + 20
|
|
|
+
|
|
|
+ pageControl.snp.remakeConstraints { (make) in
|
|
|
+ make.bottom.equalTo(-30)
|
|
|
+ make.height.equalTo(5)
|
|
|
+ make.centerX.equalToSuperview()
|
|
|
+ make.width.equalTo(pageControlWidth)
|
|
|
+ }
|
|
|
+ pageControl.numberOfPages = imageStrs.count
|
|
|
+ if pageControl.numberOfPages > 1 {
|
|
|
+ pageControl.isHidden = false
|
|
|
+ }else {
|
|
|
+ pageControl.isHidden = true
|
|
|
+ }
|
|
|
}
|
|
|
if !(images.isEmpty ){
|
|
|
- pageControl.numberOfPages = images.count
|
|
|
if images.count == 1 {
|
|
|
pageControl.isHidden = true
|
|
|
}else {
|
|
|
pageControl.isHidden = true
|
|
|
}
|
|
|
+ pageControl.numberOfPages = images.count
|
|
|
+
|
|
|
+
|
|
|
+ let pageControlWidth = CGFloat((images.count - 1) * 10) + 20
|
|
|
+
|
|
|
+ pageControl.snp.remakeConstraints { (make) in
|
|
|
+ make.bottom.equalTo(-30)
|
|
|
+ make.height.equalTo(5)
|
|
|
+ make.centerX.equalToSuperview()
|
|
|
+ make.width.equalTo(pageControlWidth)
|
|
|
+ }
|
|
|
+ pageControl.numberOfPages = images.count
|
|
|
+ if pageControl.numberOfPages > 1 {
|
|
|
+ pageControl.isHidden = false
|
|
|
+ }else {
|
|
|
+ pageControl.isHidden = true
|
|
|
+ }
|
|
|
}
|
|
|
pageControl.isUserInteractionEnabled = false
|
|
|
pageControl.currentPage = index
|
|
@@ -115,6 +154,8 @@ class BrowsePicturesViewController: BaseViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//隐藏状态栏
|
|
|
override var prefersStatusBarHidden: Bool {
|
|
|
return true
|