Merge remote-tracking branch 'upstream/master'
Conflicts: SKPhotoBrowser/SKCaptionView.swift SKPhotoBrowser/SKPhotoBrowser.swift SKPhotoBrowser/SKZoomingScrollView.swift
This commit is contained in:
commit
8a700d0b0c
|
|
@ -13,6 +13,7 @@ Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written
|
|||
- Minimalistic Facebook-like interface, swipe up/down to dismiss
|
||||
- has simple ability to custom photobrowser. (hide/show statusbar, some toolbar for controls, swipe control)
|
||||
- Handling and caching photos from web
|
||||
- Landscape handling.
|
||||
|
||||

|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = "SKPhotoBrowser"
|
||||
s.version = "1.0.1"
|
||||
s.version = "1.1.0"
|
||||
s.summary = "Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift2.0."
|
||||
s.homepage = "https://github.com/suzuki-0000/SKPhotoBrowser"
|
||||
s.license = { :type => "MIT", :file => "LICENSE" }
|
||||
s.author = { "suzuki_keishi" => "keishi.1983@gmail.com" }
|
||||
s.source = { :git => "https://github.com/suzuki-0000/SKPhotoBrowser.git", :tag => "1.0.1" }
|
||||
s.source = { :git => "https://github.com/suzuki-0000/SKPhotoBrowser.git", :tag => "1.1.0" }
|
||||
s.platform = :ios, "8.0"
|
||||
s.source_files = "SKPhotoBrowser/**/*.{h,swift}"
|
||||
s.resources = "SKPhotoBrowser/SKPhotoBrowser.bundle"
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@
|
|||
|
||||
/* Begin PBXBuildFile section */
|
||||
8909B5341BC791280060A053 /* SKPhotoBrowser.h in Headers */ = {isa = PBXBuildFile; fileRef = 8909B5331BC791280060A053 /* SKPhotoBrowser.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
8909B5431BC791510060A053 /* SKCaptionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B53B1BC791510060A053 /* SKCaptionView.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
8909B5441BC791510060A053 /* SKDetectingImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B53C1BC791510060A053 /* SKDetectingImageView.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
8909B5451BC791510060A053 /* SKDetectingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B53D1BC791510060A053 /* SKDetectingView.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
8909B5461BC791510060A053 /* SKIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B53E1BC791510060A053 /* SKIndicatorView.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
8909B5471BC791510060A053 /* SKPhoto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B53F1BC791510060A053 /* SKPhoto.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
8909B5491BC791510060A053 /* SKPhotoBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B5411BC791510060A053 /* SKPhotoBrowser.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
8909B54A1BC791510060A053 /* SKZoomingScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B5421BC791510060A053 /* SKZoomingScrollView.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
8909B54D1BC7916E0060A053 /* SKPhotoBrowser.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 8909B54C1BC7916E0060A053 /* SKPhotoBrowser.bundle */; settings = {ASSET_TAGS = (); }; };
|
||||
8909B5431BC791510060A053 /* SKCaptionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B53B1BC791510060A053 /* SKCaptionView.swift */; };
|
||||
8909B5441BC791510060A053 /* SKDetectingImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B53C1BC791510060A053 /* SKDetectingImageView.swift */; };
|
||||
8909B5451BC791510060A053 /* SKDetectingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B53D1BC791510060A053 /* SKDetectingView.swift */; };
|
||||
8909B5461BC791510060A053 /* SKIndicatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B53E1BC791510060A053 /* SKIndicatorView.swift */; };
|
||||
8909B5471BC791510060A053 /* SKPhoto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B53F1BC791510060A053 /* SKPhoto.swift */; };
|
||||
8909B5491BC791510060A053 /* SKPhotoBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B5411BC791510060A053 /* SKPhotoBrowser.swift */; };
|
||||
8909B54A1BC791510060A053 /* SKZoomingScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8909B5421BC791510060A053 /* SKZoomingScrollView.swift */; };
|
||||
8909B54D1BC7916E0060A053 /* SKPhotoBrowser.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 8909B54C1BC7916E0060A053 /* SKPhotoBrowser.bundle */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
|
|
@ -314,6 +314,7 @@
|
|||
8909B53A1BC791280060A053 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ public class SKCaptionView: UIView {
|
|||
var screenWidth :CGFloat { return screenBound.size.width }
|
||||
var screenHeight:CGFloat { return screenBound.size.height }
|
||||
|
||||
var photo:SKPhotoProtocol!
|
||||
var photoLabel:UILabel!
|
||||
var photoLabelPadding:CGFloat = 10
|
||||
private var photo:SKPhotoProtocol!
|
||||
private var photoLabel:UILabel!
|
||||
private var photoLabelPadding:CGFloat = 10
|
||||
|
||||
required public init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
|
|
@ -35,6 +35,7 @@ public class SKCaptionView: UIView {
|
|||
|
||||
func setup() {
|
||||
opaque = false
|
||||
autoresizingMask = [.FlexibleWidth, .FlexibleTopMargin, .FlexibleRightMargin, .FlexibleLeftMargin]
|
||||
|
||||
// setup background first
|
||||
let fadeView = UIView(frame: CGRectMake(0, -100, screenWidth, bounds.size.height))
|
||||
|
|
@ -49,10 +50,10 @@ public class SKCaptionView: UIView {
|
|||
photoLabel.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
|
||||
photoLabel.opaque = false
|
||||
photoLabel.backgroundColor = .clearColor()
|
||||
photoLabel.textColor = .whiteColor()
|
||||
photoLabel.textAlignment = .Center
|
||||
photoLabel.lineBreakMode = .ByWordWrapping
|
||||
photoLabel.numberOfLines = 3
|
||||
photoLabel.textColor = .whiteColor()
|
||||
photoLabel.shadowColor = UIColor(white: 0.0, alpha: 0.5)
|
||||
photoLabel.shadowOffset = CGSizeMake(0.0, 1.0)
|
||||
photoLabel.font = UIFont.systemFontOfSize(17.0)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ import UIKit
|
|||
|
||||
class SKDetectingImageView:UIImageView{
|
||||
|
||||
weak var delegate:SKDetectingImageViewDelegate?
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
}
|
||||
|
|
@ -24,8 +26,6 @@ class SKDetectingImageView:UIImageView{
|
|||
userInteractionEnabled = true
|
||||
}
|
||||
|
||||
weak var delegate:SKDetectingImageViewDelegate?
|
||||
|
||||
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
|
||||
super.touchesEnded(touches, withEvent: event)
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class SKDetectingView:UIView{
|
|||
func handleSingleTap(touch: UITouch) {
|
||||
delegate?.handleSingleTap(self, touch: touch)
|
||||
}
|
||||
|
||||
func handleDoubleTap(touch: UITouch) {
|
||||
delegate?.handleDoubleTap(self, touch: touch)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ public let SKPHOTO_LOADING_DID_END_NOTIFICATION = "photoLoadingDidEndNotificatio
|
|||
// MARK: - SKPhotoBrowser
|
||||
public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate{
|
||||
|
||||
final let pageIndexTagOffset = 1000
|
||||
final let pageIndexTagOffset:Int = 1000
|
||||
// animation property
|
||||
final let animationDuration:Double = 0.35
|
||||
|
||||
// device property
|
||||
final let screenBound = UIScreen.mainScreen().bounds
|
||||
|
|
@ -34,22 +36,45 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate{
|
|||
public var isForceStatusBarHidden:Bool = false
|
||||
|
||||
// tool for controls
|
||||
var applicationWindow:UIWindow!
|
||||
var toolBar:UIToolbar!
|
||||
var toolCounterLabel:UILabel!
|
||||
var toolCounterButton:UIBarButtonItem!
|
||||
var toolPreviousButton:UIBarButtonItem!
|
||||
var toolNextButton:UIBarButtonItem!
|
||||
var pagingScrollView:UIScrollView!
|
||||
var panGesture:UIPanGestureRecognizer!
|
||||
var doneButton:UIButton!
|
||||
var doneButtonShowFrame:CGRect = CGRectMake(5, 5, 44, 44)
|
||||
var doneButtonHideFrame:CGRect = CGRectMake(5, -20, 44, 44)
|
||||
private var applicationWindow:UIWindow!
|
||||
private var toolBar:UIToolbar!
|
||||
private var toolCounterLabel:UILabel!
|
||||
private var toolCounterButton:UIBarButtonItem!
|
||||
private var toolPreviousButton:UIBarButtonItem!
|
||||
private var toolNextButton:UIBarButtonItem!
|
||||
private var pagingScrollView:UIScrollView!
|
||||
private var panGesture:UIPanGestureRecognizer!
|
||||
private var doneButton:UIButton!
|
||||
private var doneButtonShowFrame:CGRect = CGRectMake(5, 5, 44, 44)
|
||||
private var doneButtonHideFrame:CGRect = CGRectMake(5, -20, 44, 44)
|
||||
|
||||
// photo's paging
|
||||
var visiblePages:Set<SKZoomingScrollView> = Set()
|
||||
var initialPageIndex:Int = 0
|
||||
var currentPageIndex:Int = 0
|
||||
private var visiblePages:Set<SKZoomingScrollView> = Set()
|
||||
private var initialPageIndex:Int = 0
|
||||
private var currentPageIndex:Int = 0
|
||||
|
||||
// senderView's property
|
||||
private var senderViewForAnimation:UIView?
|
||||
private var senderViewOriginalFrame:CGRect = CGRectZero
|
||||
private var senderOriginImage:UIImage!
|
||||
|
||||
private var resizableImageView:UIImageView = UIImageView()
|
||||
|
||||
// for status check property
|
||||
private var isDraggingPhoto:Bool = false
|
||||
private var isViewActive:Bool = false
|
||||
private var isPerformingLayout:Bool = false
|
||||
private var isStatusBarOriginallyHidden:Bool = false
|
||||
|
||||
// scroll property
|
||||
private var firstX:CGFloat = 0.0
|
||||
private var firstY:CGFloat = 0.0
|
||||
|
||||
// timer
|
||||
private var controlVisibilityTimer:NSTimer!
|
||||
|
||||
// delegate
|
||||
public weak var delegate: SKPhotoBrowserDelegate?
|
||||
|
||||
// photos
|
||||
var photos:[SKPhotoProtocol] = [SKPhotoProtocol]()
|
||||
|
|
@ -57,31 +82,7 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate{
|
|||
return photos.count
|
||||
}
|
||||
|
||||
// senderView's property
|
||||
var senderViewForAnimation:UIView?
|
||||
var senderViewOriginalFrame:CGRect = CGRectZero
|
||||
var senderOriginImage:UIImage!
|
||||
|
||||
// animation property
|
||||
let animationDuration:Double = 0.35
|
||||
var resizableImageView:UIImageView = UIImageView()
|
||||
|
||||
// for status check
|
||||
var isDraggingPhoto:Bool = false
|
||||
var isViewActive:Bool = false
|
||||
var isPerformingLayout:Bool = false
|
||||
var isStatusBarOriginallyHidden:Bool = false
|
||||
|
||||
// scroll property
|
||||
var firstX:CGFloat = 0.0
|
||||
var firstY:CGFloat = 0.0
|
||||
|
||||
// timer
|
||||
var controlVisibilityTimer:NSTimer!
|
||||
|
||||
// delegate
|
||||
weak public var delegate: SKPhotoBrowserDelegate?
|
||||
|
||||
// MARK - Initializer
|
||||
required public init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
setup()
|
||||
|
|
@ -124,8 +125,6 @@ public class SKPhotoBrowser: UIViewController, UIScrollViewDelegate{
|
|||
NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleSKPhotoLoadingDidEndNotification:", name: SKPHOTO_LOADING_DID_END_NOTIFICATION, object: nil)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: - override
|
||||
public override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import UIKit
|
|||
|
||||
public class SKZoomingScrollView:UIScrollView, UIScrollViewDelegate, SKDetectingViewDelegate, SKDetectingImageViewDelegate{
|
||||
|
||||
weak var photoBrowser:SKPhotoBrowser!
|
||||
var captionView:SKCaptionView!
|
||||
var photo:SKPhotoProtocol!{
|
||||
didSet{
|
||||
photoImageView.image = nil
|
||||
|
|
@ -18,10 +18,10 @@ public class SKZoomingScrollView:UIScrollView, UIScrollViewDelegate, SKDetecting
|
|||
}
|
||||
}
|
||||
|
||||
var captionView:SKCaptionView!
|
||||
var tapView:SKDetectingView!
|
||||
var photoImageView:SKDetectingImageView!
|
||||
var indicatorView: SKIndicatorView!
|
||||
private weak var photoBrowser:SKPhotoBrowser!
|
||||
private var tapView:SKDetectingView!
|
||||
private var photoImageView:SKDetectingImageView!
|
||||
private var indicatorView: SKIndicatorView!
|
||||
|
||||
required public init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
|
|
@ -51,7 +51,8 @@ public class SKZoomingScrollView:UIScrollView, UIScrollViewDelegate, SKDetecting
|
|||
// image
|
||||
photoImageView = SKDetectingImageView(frame: frame)
|
||||
photoImageView.delegate = self
|
||||
photoImageView.backgroundColor = UIColor.clearColor()
|
||||
photoImageView.contentMode = .Center
|
||||
photoImageView.backgroundColor = .clearColor()
|
||||
addSubview(photoImageView)
|
||||
|
||||
// indicator
|
||||
|
|
@ -59,20 +60,21 @@ public class SKZoomingScrollView:UIScrollView, UIScrollViewDelegate, SKDetecting
|
|||
addSubview(indicatorView)
|
||||
|
||||
// self
|
||||
backgroundColor = UIColor.clearColor()
|
||||
backgroundColor = .clearColor()
|
||||
delegate = self
|
||||
showsHorizontalScrollIndicator = false
|
||||
showsVerticalScrollIndicator = false
|
||||
decelerationRate = UIScrollViewDecelerationRateFast
|
||||
autoresizingMask = [.FlexibleHeight, .FlexibleWidth]
|
||||
autoresizingMask = [.FlexibleWidth, .FlexibleTopMargin, .FlexibleBottomMargin, .FlexibleRightMargin, .FlexibleLeftMargin]
|
||||
}
|
||||
|
||||
// MARK: - override
|
||||
public override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
tapView.frame = bounds
|
||||
|
||||
super.layoutSubviews()
|
||||
|
||||
let boundsSize = bounds.size
|
||||
var frameToCenter = photoImageView.frame
|
||||
|
||||
|
|
@ -101,7 +103,7 @@ public class SKZoomingScrollView:UIScrollView, UIScrollViewDelegate, SKDetecting
|
|||
minimumZoomScale = 1
|
||||
zoomScale = 1
|
||||
|
||||
if photoImageView == nil {
|
||||
guard let photoImageView = photoImageView else {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -110,8 +112,8 @@ public class SKZoomingScrollView:UIScrollView, UIScrollViewDelegate, SKDetecting
|
|||
|
||||
let xScale = boundsSize.width / imageSize.width
|
||||
let yScale = boundsSize.height / imageSize.height
|
||||
var maxScale:CGFloat = 4.0
|
||||
let minScale:CGFloat = min(xScale, yScale)
|
||||
var maxScale:CGFloat = 4.0
|
||||
|
||||
maximumZoomScale = maxScale
|
||||
minimumZoomScale = minScale
|
||||
|
|
|
|||
Loading…
Reference in New Issue