Skip to content

Commit

Permalink
Merge branch 'master' into customDirection
Browse files Browse the repository at this point in the history
  • Loading branch information
quver authored Jan 4, 2017
2 parents 20606c3 + f473224 commit 641ac69
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 23 deletions.
Binary file removed Graphics/slider-HiRes.png
Binary file not shown.
Binary file removed Graphics/slider.afdesign
Binary file not shown.
Binary file removed Graphics/slider.png
Binary file not shown.
Binary file removed Graphics/slider@2x.png
Binary file not shown.
Binary file removed Graphics/slider@3x.png
Binary file not shown.
4 changes: 4 additions & 0 deletions SlidableImage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
D55BB1951CB97A10000B2875 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D55BB1931CB97A10000B2875 /* LaunchScreen.storyboard */; };
D55BB1A01CB97A10000B2875 /* SlidableImageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D55BB19F1CB97A10000B2875 /* SlidableImageTests.swift */; };
D565D0A51DCD6B2D0028788A /* SlidableImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D565D0A41DCD6B2D0028788A /* SlidableImage.swift */; };
D5C164DA1E07260700606F9F /* ArrowsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5C164D91E07260700606F9F /* ArrowsView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -38,6 +39,7 @@
D55BB19F1CB97A10000B2875 /* SlidableImageTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SlidableImageTests.swift; sourceTree = "<group>"; };
D55BB1A11CB97A10000B2875 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D565D0A41DCD6B2D0028788A /* SlidableImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SlidableImage.swift; path = Sources/SlidableImage.swift; sourceTree = SOURCE_ROOT; };
D5C164D91E07260700606F9F /* ArrowsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ArrowsView.swift; path = Sources/ArrowsView.swift; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -82,6 +84,7 @@
D55BB18A1CB97A10000B2875 /* AppDelegate.swift */,
D55BB18C1CB97A10000B2875 /* ViewController.swift */,
D565D0A41DCD6B2D0028788A /* SlidableImage.swift */,
D5C164D91E07260700606F9F /* ArrowsView.swift */,
D55BB18E1CB97A10000B2875 /* Main.storyboard */,
D55BB1911CB97A10000B2875 /* Assets.xcassets */,
D55BB1931CB97A10000B2875 /* LaunchScreen.storyboard */,
Expand Down Expand Up @@ -203,6 +206,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D5C164DA1E07260700606F9F /* ArrowsView.swift in Sources */,
D55BB18D1CB97A10000B2875 /* ViewController.swift in Sources */,
D565D0A51DCD6B2D0028788A /* SlidableImage.swift in Sources */,
D55BB18B1CB97A10000B2875 /* AppDelegate.swift in Sources */,
Expand Down
23 changes: 0 additions & 23 deletions SlidableImage/Assets.xcassets/slider.imageset/Contents.json

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
68 changes: 68 additions & 0 deletions Sources/ArrowsView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// ArrowsView.swift
// SlidableImage
//
// Created by Pawel Bednorz on 18.12.2016.
// Copyright © 2016 Quver. All rights reserved.
//

import UIKit

class ArrowsView: UIView {

override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .clear
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
backgroundColor = .clear
}

override func draw(_ rect: CGRect) {
drawCircle(rect)
drawArrows(rect)
}

private func drawCircle(_ rect: CGRect) {
let circle = UIBezierPath(ovalIn: rect)
let circleLayer = CAShapeLayer()
circleLayer.path = circle.cgPath
circleLayer.fillColor = UIColor.lightGray.cgColor
circleLayer.shadowColor = UIColor.darkGray.cgColor
circleLayer.shadowOpacity = 1
circleLayer.shadowOffset = CGSize.zero
circleLayer.shadowRadius = 10
layer.addSublayer(circleLayer)
}

private func drawArrows(_ rect: CGRect) {
let factor: CGFloat = rect.width * 0.05

let startPointLeft = CGPoint(x: (rect.minX + 2 * factor), y: rect.midY)
let arrowLeft = UIBezierPath()
arrowLeft.move(to: startPointLeft)
arrowLeft.addLine(to: CGPoint(x: (rect.midX - factor), y: rect.minY + 2 * factor))
arrowLeft.addLine(to: CGPoint(x: (rect.midX - factor), y: rect.maxY - 2 * factor))
arrowLeft.addLine(to: startPointLeft)

let arrowLeftLayer = CAShapeLayer()
arrowLeftLayer.path = arrowLeft.cgPath
arrowLeftLayer.fillColor = UIColor.white.cgColor
layer.addSublayer(arrowLeftLayer)

let startPointRight = CGPoint(x: (rect.maxX - 2 * factor), y: rect.midY)
let arrowRight = UIBezierPath()
arrowRight.move(to: startPointRight)
arrowRight.addLine(to: CGPoint(x: (rect.midX + factor), y: rect.minY + 2 * factor))
arrowRight.addLine(to: CGPoint(x: (rect.midX + factor), y: rect.maxY - 2 * factor))
arrowRight.addLine(to: startPointRight)

let arrowRightLayer = CAShapeLayer()
arrowRightLayer.path = arrowRight.cgPath
arrowRightLayer.fillColor = UIColor.white.cgColor
layer.addSublayer(arrowRightLayer)
}

}
5 changes: 5 additions & 0 deletions Sources/SlidableImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ open class SlidableImage: UIView {
private class func setupSliderCircle(sliderImage: UIImage? = nil) -> UIView {
// Workaround - without this view, gesture recognizer doesn't work
let circle = UIView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))

guard let sliderImage = sliderImage else {
return ArrowsView(frame: frame)
}

circle.layer.cornerRadius = circle.bounds.width / 2

let imageView = UIImageView(image: sliderImage)
Expand Down

0 comments on commit 641ac69

Please sign in to comment.