diff --git a/Example/MSSnappingSlider/Base.lproj/Main.storyboard b/Example/MSSnappingSlider/Base.lproj/Main.storyboard
index 4b5a9ba..90a3e7d 100644
--- a/Example/MSSnappingSlider/Base.lproj/Main.storyboard
+++ b/Example/MSSnappingSlider/Base.lproj/Main.storyboard
@@ -24,17 +24,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Example/MSSnappingSlider/ViewController.swift b/Example/MSSnappingSlider/ViewController.swift
index c3be52f..206bf88 100644
--- a/Example/MSSnappingSlider/ViewController.swift
+++ b/Example/MSSnappingSlider/ViewController.swift
@@ -12,6 +12,7 @@ import MSSnappingSlider
class ViewController: UIViewController {
@IBOutlet weak var mySlider: MSSnappingSlider!
+ @IBOutlet weak var valueLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
@@ -27,7 +28,7 @@ class ViewController: UIViewController {
extension ViewController: MSSnappingSliderDelegate {
func snappingSlider(_ snappingSlider: MSSnappingSlider, didChangeValueTo newValue: Float) {
- print(newValue)
+ valueLabel.text = "\(newValue)"
}
}
diff --git a/Example/Podfile.lock b/Example/Podfile.lock
index 2de26a9..d1490cb 100644
--- a/Example/Podfile.lock
+++ b/Example/Podfile.lock
@@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"
SPEC CHECKSUMS:
- MSSnappingSlider: 015dcaa712dcd893cbe8eadd0ddc9d23deb10606
+ MSSnappingSlider: 0ad29efa0522ce43f8119fa29a084c51f76172f1
PODFILE CHECKSUM: 6093b1b896405af454bb63c4a96b797ab6813e4f
diff --git a/Example/Pods/Local Podspecs/MSSnappingSlider.podspec.json b/Example/Pods/Local Podspecs/MSSnappingSlider.podspec.json
index 7045bb5..dbebfe1 100644
--- a/Example/Pods/Local Podspecs/MSSnappingSlider.podspec.json
+++ b/Example/Pods/Local Podspecs/MSSnappingSlider.podspec.json
@@ -1,8 +1,8 @@
{
"name": "MSSnappingSlider",
"version": "0.1.0",
- "summary": "A short description of MSSnappingSlider.",
- "description": "TODO: Add long description of the pod here.",
+ "summary": "Subclass of UISlider which snaps to specific values based on the step value provided.",
+ "description": "MSSnappingSlider is a subclass of `UISlider` that will give you access to 2 attributes, `step` and `threshold` where you can define exactly how the snapping should work.",
"homepage": "https://github.com/MaherKSantina/MSSnappingSlider",
"license": {
"type": "MIT",
diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock
index 2de26a9..d1490cb 100644
--- a/Example/Pods/Manifest.lock
+++ b/Example/Pods/Manifest.lock
@@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"
SPEC CHECKSUMS:
- MSSnappingSlider: 015dcaa712dcd893cbe8eadd0ddc9d23deb10606
+ MSSnappingSlider: 0ad29efa0522ce43f8119fa29a084c51f76172f1
PODFILE CHECKSUM: 6093b1b896405af454bb63c4a96b797ab6813e4f
diff --git a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/MSSnappingSlider.xcscheme b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/MSSnappingSlider.xcscheme
new file mode 100644
index 0000000..f06b247
--- /dev/null
+++ b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/MSSnappingSlider.xcscheme
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/MSSnappingSlider.podspec b/MSSnappingSlider.podspec
index acf3414..0419eb4 100644
--- a/MSSnappingSlider.podspec
+++ b/MSSnappingSlider.podspec
@@ -9,7 +9,7 @@
Pod::Spec.new do |s|
s.name = 'MSSnappingSlider'
s.version = '0.1.0'
- s.summary = 'A short description of MSSnappingSlider.'
+ s.summary = 'Subclass of UISlider which snaps to specific values based on the step value provided.'
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
-TODO: Add long description of the pod here.
+MSSnappingSlider is a subclass of `UISlider` that will give you access to 2 attributes, `step` and `threshold` where you can define exactly how the snapping should work.
DESC
s.homepage = 'https://github.com/MaherKSantina/MSSnappingSlider'
diff --git a/MSSnappingSlider/Classes/MSSnappingSlider.swift b/MSSnappingSlider/Classes/MSSnappingSlider.swift
index 58f1bd4..a60345d 100644
--- a/MSSnappingSlider/Classes/MSSnappingSlider.swift
+++ b/MSSnappingSlider/Classes/MSSnappingSlider.swift
@@ -7,11 +7,22 @@
import UIKit
+/**
+ Handles all events emitted from the snapping slider
+ */
public protocol MSSnappingSliderDelegate: AnyObject {
+
+ /**
+ Will be called whenever the slider snaps to a value, or the user lifts their hand from the slider. Note: This delegate function will sometimes be called multiple times for the same value. This happens when users drag to a new value and lift their finger up.
+ - parameter snappingSlider: The slider that its value changed
+ - parameter newValue: The new snapped value that the slider reached
+ */
func snappingSlider(_ snappingSlider: MSSnappingSlider, didChangeValueTo newValue: Float)
}
public extension MSSnappingSliderDelegate {
+
+ // Default implementation for the change value event
func snappingSlider(_ snappingSlider: MSSnappingSlider, didChangeValueTo newValue: Float) {}
}
diff --git a/README.md b/README.md
index 1a55af1..bf21bfe 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,26 @@
# MSSnappingSlider
-[![CI Status](https://img.shields.io/travis/MaherKSantina/MSSnappingSlider.svg?style=flat)](https://travis-ci.org/MaherKSantina/MSSnappingSlider)
-[![Version](https://img.shields.io/cocoapods/v/MSSnappingSlider.svg?style=flat)](https://cocoapods.org/pods/MSSnappingSlider)
-[![License](https://img.shields.io/cocoapods/l/MSSnappingSlider.svg?style=flat)](https://cocoapods.org/pods/MSSnappingSlider)
-[![Platform](https://img.shields.io/cocoapods/p/MSSnappingSlider.svg?style=flat)](https://cocoapods.org/pods/MSSnappingSlider)
+MSSnappingSlider is a subclass of `UISlider` that will give you access to 2 attributes, `step` and `threshold` where you can define exactly how the snapping should work.
+
+![Snapping Slider](https://user-images.githubusercontent.com/24646608/59196589-6d05cb00-8bd2-11e9-99f9-8e398f08c7ce.gif)
+
+## Specifications
+### `step`
+`step` defines the value of the displacement.
+For example, if the `step` is `1`, the slider will only snap to integer value (1.0, 2.0, -1.0 ...)
+
+### `threshold`
+`threshold` is the maximum magnitude that the value can reach before snapping to the adjacent value.
+For example, if the `step` is `1` and the `threshold` is `0.5`, as soon as the slider value passes `0.5`, it will snap to `1`
+
+### `MSSnappingSliderDelegate`
+Handles all events emitted from the snapping slider. It has only one function:
+
+```swift
+func snappingSlider(_ snappingSlider: MSSnappingSlider, didChangeValueTo newValue: Float)
+```
+
+This function will be called whenever the slider snaps to a value, or the user lifts their hand from the slider. Note: This delegate function will sometimes be called multiple times for the same value. This happens when users drag to a new value and lift their finger up.
## Example
@@ -11,8 +28,11 @@ To run the example project, clone the repo, and run `pod install` from the Examp
## Requirements
+XCode 10.2
+
## Installation
+### Cocoapods
MSSnappingSlider is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:
@@ -20,6 +40,12 @@ it, simply add the following line to your Podfile:
pod 'MSSnappingSlider'
```
+### Carthage
+
+```ruby
+github "MSSnappingSlider"
+```
+
## Author
MaherKSantina, maher.santina90@gmail.com