Skip to content

Commit

Permalink
Merge pull request #54 from onmyway133/fix/center
Browse files Browse the repository at this point in the history
Update noImagesLabel
  • Loading branch information
RamonGilabert committed Nov 12, 2015
2 parents a57ba4f + f368b33 commit 82e66c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 11 additions & 1 deletion Source/ImageGallery/ImageGalleryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,19 @@ public class ImageGalleryView: UIView {
width: Dimensions.indicatorWidth, height: Dimensions.indicatorHeight)
collectionView.frame = CGRect(x: 0, y: topSeparator.frame.height, width: totalWidth, height: collectionFrame - topSeparator.frame.height)
collectionSize = CGSize(width: collectionView.frame.height, height: collectionView.frame.height)
noImagesLabel.center = collectionView.center

updateNoImagesLabel()
}

func updateNoImagesLabel() {
let height = CGRectGetHeight(bounds)
let threshold = Dimensions.galleryBarHeight * 2

noImagesLabel.center = CGPoint(x: CGRectGetWidth(bounds)/2, y: height/2)
noImagesLabel.alpha = (height > threshold) ? 1 : (height - Dimensions.galleryBarHeight) / threshold
}


// MARK: - Photos handler

func fetchPhotos(completion: (() -> Void)? = nil) {
Expand Down
5 changes: 3 additions & 2 deletions Source/ImagePickerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ public class ImagePickerController: UIViewController {
let constant = maximum ? GestureConstants.maximumHeight : GestureConstants.minimumHeight
galleryView.collectionView.frame.size.height = constant - galleryView.topSeparator.frame.height
galleryView.collectionSize = CGSize(width: galleryView.collectionView.frame.height, height: galleryView.collectionView.frame.height)
galleryView.noImagesLabel.center = galleryView.collectionView.center

galleryView.updateNoImagesLabel()
}

func enableGestures(enabled: Bool) {
Expand Down Expand Up @@ -334,7 +335,7 @@ extension ImagePickerController: ImageGalleryPanGestureDelegate {
galleryView.frame.size.height = initialFrame.height - translation.y
}

galleryView.noImagesLabel.center = galleryView.collectionView.center
galleryView.updateNoImagesLabel()
}

func panGestureDidEnd(translation: CGPoint, velocity: CGPoint) {
Expand Down

0 comments on commit 82e66c5

Please sign in to comment.