#94. and minor refactor.

This commit is contained in:
suzuki_keishi 2016-05-13 15:42:44 +09:00
parent d5d95e0a47
commit adfceff42f
3 changed files with 19 additions and 9 deletions

View File

@ -147,13 +147,6 @@ let browser = SKPhotoBrowser(originImage: originImage, photos: images, animatedF
browser.disableVerticalSwipe = true
```
#### StatusBar
you can hide statusbar forcely using property:
``` swift
let browser = SKPhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
browser.isForceStatusBarHidden = true
```
#### Delegate
There's some trigger point you can handle using delegate. those are optional.
- didShowPhotoAtIndex(index:Int)
@ -181,6 +174,16 @@ func didDismissAtPageIndex(index: Int) {
```
#### Minor Option
- blackArea handling which is appearing outside of photo
- single tap handling, dismiss/noaction
- bounce animation when appearing/dismissing
``` swift
enableZoomBlackArea = true // default true
enableSingleTapDismiss = true // default false
bounceAnimation = true // default false
```
## Photos from
- [Unsplash](https://unsplash.com)

View File

@ -108,6 +108,7 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate {
public var displayCustomDeleteButton = false
public var bounceAnimation = false
public var enableZoomBlackArea = true
public var enableSingleTapDismiss = false
/// Set nil to force the statusbar to be hidden
public var statusBarStyle: UIStatusBarStyle?
@ -662,7 +663,7 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate {
deleteButtonShowFrame = CGRect(x: view.frame.width - 44, y: buttonTopOffset, width: 44, height: 44)
deleteButtonHideFrame = CGRect(x: view.frame.width - 44, y: -20, width: 44, height: 44)
}
if displayCustomDeleteButton {
if displayCustomDeleteButton {
customDeleteButtonShowFrame = CGRect(x: customDeleteButtonShowFrame.origin.y, y: customDeleteButtonShowFrame.origin.x, width: customDeleteButtonShowFrame.width, height: customDeleteButtonShowFrame.height)
customDeleteButtonHideFrame = CGRect(x: customDeleteButtonHideFrame.origin.y, y: customDeleteButtonHideFrame.origin.x, width: customDeleteButtonHideFrame.width, height: customDeleteButtonHideFrame.height)
}
@ -911,7 +912,7 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate {
}
}
private func determineAndClose() {
public func determineAndClose() {
delegate?.willDismissAtPageIndex?(currentPageIndex)
let scrollView = pageDisplayedAtIndex(currentPageIndex)

View File

@ -270,6 +270,9 @@ public class SKZoomingScrollView: UIScrollView, UIScrollViewDelegate, SKDetectin
// MARK: - SKDetectingViewDelegate
func handleSingleTap(view: UIView, touch: UITouch) {
if photoBrowser?.enableZoomBlackArea == true {
if photoBrowser?.areControlsHidden() == false && photoBrowser?.enableSingleTapDismiss == true {
photoBrowser?.determineAndClose()
}
photoBrowser?.toggleControls()
}
}
@ -304,6 +307,9 @@ public class SKZoomingScrollView: UIScrollView, UIScrollViewDelegate, SKDetectin
// MARK: - SKDetectingImageViewDelegate
func handleImageViewSingleTap(view: UIImageView, touch: UITouch) {
if photoBrowser?.areControlsHidden() == false && photoBrowser?.enableSingleTapDismiss == true {
photoBrowser?.determineAndClose()
}
photoBrowser?.toggleControls()
}