From 98ad36bb0a118521116ebd23674a2f0efb97ed03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bednorz?= Date: Thu, 14 Apr 2016 00:56:11 +0200 Subject: [PATCH] Documentation update --- SlidableImage.podspec | 2 +- SlidableImage/SlidableImage.swift | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/SlidableImage.podspec b/SlidableImage.podspec index e9e36d0..6b521d6 100644 --- a/SlidableImage.podspec +++ b/SlidableImage.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "SlidableImage" - s.version = "1.0.1" + s.version = "1.0.2" s.license = "MIT" s.summary = "Fancy slider for before&after images" s.homepage = "https://github.com/quver/SlidableImage" diff --git a/SlidableImage/SlidableImage.swift b/SlidableImage/SlidableImage.swift index ca84bf4..1e1f160 100644 --- a/SlidableImage/SlidableImage.swift +++ b/SlidableImage/SlidableImage.swift @@ -8,22 +8,23 @@ import UIKit -class SlidableImage: UIView { +/// Super easy Slider for before&after images +public class SlidableImage: UIView { /** First image container view. You can override it with your custom view. */ - var firstView: UIView + public var firstView: UIView /** Second image container view. You can override it with your custom view. */ - var secondView: UIView + public var secondView: UIView /** Circle view with icon for sliding images. You can override it with your custom view. */ - var sliderCircle: UIView + public var sliderCircle: UIView /** Generic initializer with views @@ -34,7 +35,7 @@ class SlidableImage: UIView { - returns: instance */ - init(frame: CGRect, firstView: UIView, secondView: UIView) { + public init(frame: CGRect, firstView: UIView, secondView: UIView) { self.firstView = firstView self.secondView = secondView sliderCircle = SlidableImage.prepareSliderCircle() @@ -48,12 +49,12 @@ class SlidableImage: UIView { Short way to initialize SlidableView. You need target size and images. - parameter frame: Frame size - - parameter firstImage: Sirst image for sliding + - parameter firstImage: First image for sliding - parameter secondImage: Second image for sliding - returns: instance */ - convenience init(frame: CGRect, firstImage: UIImage, secondImage: UIImage) { + convenience public init(frame: CGRect, firstImage: UIImage, secondImage: UIImage) { let firstView = UIImageView(frame: frame) firstView.image = UIImage(named: "draw") firstView.contentMode = .ScaleAspectFill @@ -65,7 +66,7 @@ class SlidableImage: UIView { self.init(frame: frame, firstView: firstView, secondView: secondView) } - required init?(coder aDecoder: NSCoder) { + required public init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -74,7 +75,7 @@ class SlidableImage: UIView { - parameter maskLocation: x-axis location in frame, where image should be slided */ - func updateMask(maskLocation: CGFloat) { + public func updateMask(maskLocation: CGFloat) { let maskRectPath = UIBezierPath(rect: CGRect(x: self.bounds.minX, y: bounds.minY, width: maskLocation, height: bounds.height)) let mask = CAShapeLayer() mask.path = maskRectPath.CGPath @@ -83,6 +84,9 @@ class SlidableImage: UIView { sliderCircle.center.x = maskLocation } + /** + Private wrapper for setup view + */ private func initializeView() { clipsToBounds = true sliderCircle.center = center @@ -93,6 +97,9 @@ class SlidableImage: UIView { addSubview(sliderCircle) } + /** + Private wrapper for adding gesture recognizer + */ private func initializeGestureRecognizer() { let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(gestureHandler)) sliderCircle.addGestureRecognizer(panGestureRecognizer) @@ -109,6 +116,9 @@ class SlidableImage: UIView { } + /** + Private wrapper for setup circle slider view + */ private class func prepareSliderCircle() -> UIView { // Workaround - without this view, gesture recognizer doesn't work let circle = UIView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))