yonat / multislider Goto Github PK
View Code? Open in Web Editor NEWUISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizontal.
License: MIT License
UISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizontal.
License: MIT License
Description:
Is there a simple way to disable half the thumb protruding outside of its track? I want the end of the thumb to align perfectly with the end of the track.
Description of the problem:
I have a slider with two thumbs. When I set keepsDistanceBetweenThumbs = true and distanceBetweenThumbs = 0 both thumbs overlaps but the slider value maintains a distance. And also this problem only occurs when we run the app greater than regular size iPhone. It also occurs when keepsDistanceBetweenThumbs = false.
Snap of my Code:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
slider()
}
func slider() {
var slider = MultiSlider()
slider.translatesAutoresizingMaskIntoConstraints = false
self.view.addSubview(slider)
slider.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 200).isActive = true
slider.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 50).isActive = true
slider.widthAnchor.constraint(equalToConstant: 200).isActive = true
slider.heightAnchor.constraint(equalToConstant: 100).isActive = true
slider.orientation = .horizontal
slider.tintColor = UIColor.red
slider.outerTrackColor = UIColor.green
slider.trackWidth = 3
slider.showsThumbImageShadow = false
slider.maximumValue = 143148.11
slider.minimumValue = 125728.91
slider.value = [125728.91, 143148.11]
slider.keepsDistanceBetweenThumbs = true
slider.distanceBetweenThumbs = 0
slider.addTarget(self, action: #selector(sliderChanged), for: .valueChanged)
}
@objc func sliderChanged(slider: MultiSlider) {
print("thumb \(slider.draggedThumbIndex) moved")
print("now thumbs are at \(slider.value)") // when overlap I get [125728.91, 125711.93] when right thumb at left most position
}
I'm on Xcode 8.2.1
I pulled down master branch. Ran pod install in example folder. Opened .xcworkspace file and tried to build.
Then I got this error: No such module 'MiniLayout'.
When both thumbs are on the same value, the lower bound one cannot slide back down
it just keeps crushing when trying to assign:
self.multiSlider.thumbViews = [imageView1,imageView2,imageView3]
it gives
'Unable to install constraint on view. Does the constraint reference something from outside the subtree of the view?'
I've tried adding imageviews to view hierarchy to main view and even multislider
I use multi slider from xib. Create UIView and set class and module to MultiSlider.
But after i run, my app crash and got an error Unknown class MultiSlider in Interface Builder file.
Hello
Description of the problem:
Is it possible that the framework relies on AvailableHapticFeedback?
I get a link error in Xcode 11.3 building an ios 12 app.
I see there is an open issue from 2019 on this.
Thanks, Thomas
Description:
Add possibility of change the center of the thumb outside. Some like @IBInspectable or public. I couldn’t do the native behavior of the thumb as in Settings in iPhone on the “Brightness” slider
Description of the problem:
[description]
Minimal project that reproduces the problem (so I'll be able to figure out how to fix it):
[github repo or a zipped project]
Description of the problem:
I have made an instance of the slider and simply added it as and arranged subview to my stack view but the slider is shown in a very weird way. I am attaching an image where the blue line is supposed to be the slider. I have also tried to change its orientation to .horizontal but it did not help
private var slider: MultiSlider = MultiSlider()
stack.addArrangedSubview(slider)
Unable to change the margin by which the MultiSlider sits within.
Right now that value is 32:
let margin: CGFloat = 32
Should be able to change the padding around the slider with constants that the developer is okay with.
Problems I encountered when trying to implement this myself: Had to unlock file from cocoa pods in order to change it.
Hi,
I would like to assign a different image to each individual thumb. I want to have a slider that has 3 thumbs. The left and right thumbs are my start and end thumbs, while the middle thumb is a progress thumb to show the progress of an audio/video player. I would like have the start and end thumbs have a different image while the middle progress thumb will different image. Please let me know if this is already available ? or how would I implement them.
thanks,
-Vittal
email-dot-vittal-at-gmail-dot-com
Is it possible to just use two thumbs, and make it so that left does not cross over the right? And viceversa?
Can I create a horizontal slider? Is this implemented yet? If not, have you considered adding this feature?
Hello, firstly let me thank you guys for this awesome range slider component, and then let me ask you guys if you could make a feature that allows to give each thumb it's own image.
Thank you in advance
Hi,
Which property or flag do i need to set to make it visible horizontal?
Description:
Can we get the current dragging index so that we know which slider is user trying to slider / value changes?
Problems I encountered when trying to implement this myself:
The multiple slider.value is returning array of values which I'm not sure how to get the last changing value.
I got 2 storyboard errors when I added a slider into the storyboard. They are:
error: IB Designables: Failed to render and update auto layout status for MyViewController (X4n-4q-1cD): dlopen(MultiSlider.framework, 1): Library not loaded: @rpath/MiniLayout.framework/MiniLayout
Referenced from: MultiSlider.framework
Reason: image not found
error: IB Designables: Failed to update auto layout status: dlopen(MultiSlider.framework, 1): Library not loaded: @rpath/MiniLayout.framework/MiniLayout
Referenced from: MultiSlider.framework
Reason: image not found
It's not affecting compilation though. How can I get rid of them?
Hi.
I have an issue with this slider. I'm using several MultiSliders in a tableview but when I try to scroll it, If my pan gesture starts on one of the MultiSliders, the gesture is captured by the slider and scroll doesn't work until I start panning from outside the sliders.
Is there any possibility to improve the slider to propagate the pan to superview if we needed?
Thanks.
Hello, in UITableViewCell constraints break
Description of the problem:
When implementing MultiSlider in SwiftUI Form, the height constraints break which causes the slider to disappear until I explicitly scroll back and forth to its position.
My Installation Process
File -> Swift Packages -> Add Package Dependency -> [URL: https://github.com/yonat/MultiSlider], [Branch: swiftui]
Code Snippet
Form {
Section {
VStack {
HStack {
Text("Age")
Spacer()
Text("\(Int(selectedAgeRange[0])) - \(Int(selectedAgeRange[1]))")
}.font(.title)
MultiValueSlider(
value: $selectedAgeRange,
minimumValue: 18,
maximumValue: 80,
snapStepSize: 1,
outerTrackColor: .lightGray,
keepsDistanceBetweenThumbs: true
)
}
}
}
Debug Log
When the slider is not visible
(
"<NSAutoresizingMaskLayoutConstraint:0x283b505a0 h=--& v=--& multi_slider.height == 63 (active, names: multi_slider:0x137f04cb0 )>",
"<NSLayoutConstraint:0x283b5b890 multi_slider.height == 31 (active, names: multi_slider:0x137f04cb0 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x283b5b890 multi_slider.height == 31 (active, names: multi_slider:0x137f04cb0 )>
When I scroll back & forth to its position & then slider appears
[Warning] Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a table view cell's content view. We're considering the collapse unintentional and using standard height instead. Cell: <SwiftUI.ListCoreCellHost: 0x13c214b00; baseClass = UITableViewCell; frame = (0 199.667; 374 0.666667); clipsToBounds = YES; autoresize = W; layer = <CALayer: 0x2818bd660>>
Hey @yonat,
Awesome work here. It would be great to have the option to disable the haptic feedback. In our case, we want to set a step interval, but to something small (i.e. 1.0 in a slider with a range of 39.0 - 150.0). In this case, the haptic engine fires repeatedly, so we'd like to disable it.
All the best,
Ed
ageSlider.distanceBetweenThumbs = 4 causes my app to crash every time. I do not understand why or what to do to get a minimum distance of 4 between my two sliders. Crash report says the following:
2020-04-30 18:18:45.152808-0400 Revibe[14213:2645545] -[MultiSlider.MultiSlider setDistanceBetweenThumbs:]: unrecognized selector sent to instance 0x7fbedc95c820
2020-04-30 18:18:45.164995-0400 Revibe[14213:2645545] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MultiSlider.MultiSlider setDistanceBetweenThumbs:]: unrecognized selector sent to instance 0x7fbedc95c820'
I am facing an issue where the slider track gets aligned to the top of the UIView. Has anyone faced such issue? I am attaching the screenshots of the MultiSliders along with UIDebugger screenshot. TIA.
The UIView is vertically centered to UIImageView with horizontal spacing.
This is the screenshot of UIDebugger.
Is there a possibility to set a value of each thumb ?
With the UISlider module you can move the thumb to a predefined value with
slider.setValue(value, animated: true)
Description of the problem:
let horizontalMultiSlider = MultiSlider()
horizontalMultiSlider.orientation = .vertical
horizontalMultiSlider.minimumValue = 10 / 4
horizontalMultiSlider.maximumValue = 10 / 3
horizontalMultiSlider.outerTrackColor = .gray
horizontalMultiSlider.value = [2.718, 3.14]
horizontalMultiSlider.valueLabelPosition = .top
horizontalMultiSlider.tintColor = .purple
horizontalMultiSlider.trackWidth = 32
horizontalMultiSlider.showsThumbImageShadow = false
view.addConstrainedSubview(horizontalMultiSlider, constrain: .topMargin, .leftMargin, .rightMargin, .bottomMargin)
view.layoutMargins = UIEdgeInsets(top: 32, left: 32, bottom: 32, right: 32)
horizontalMultiSlider.keepsDistanceBetweenThumbs = false
horizontalMultiSlider.valueLabelFormatter.positiveSuffix = " 𝞵s"
bug when setting orientation to .vertical
the UI show normally but can't slide
Minimal project that reproduces the problem (so I'll be able to figure out how to fix it):
I just try from the example in this repo
Description:
You currently do not have support for Carthage.
Problems I encountered when trying to implement this myself:
I'm working in a project where we are trying to remove the cocoapods, and we've moved all our libs to Carthage.
We would like to use your lib without the need to use cocoapods.
Description of the problem:
macOS Mojave 10.14.6
XCode 11.0
Simulator: iPhone 11 Pro Max (iOS 13.0)
Cannot move any thumb on the slider.
Minimal project that reproduces the problem (so I'll be able to figure out how to fix it):
https://gist.github.com/jn8029/a61bc7f0eb106bc5e71082b1536088d1
*** Assertion failure in -[NSLayoutConstraint _setMultiplier:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1562/Foundation/Layout.subproj/NSLayoutConstraint.m:196
2019-03-11 12:39:32.198830+0530 DCON[3784:1325822] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Multiplier is not finite! That's illegal. multiplier:inf'
Application crashed. ios 12 horizontal and vertical slider is not working any help
Hey there, first of all thanks for your decent work here!
My request is to remove SweeterSwift and replace calls to it with native code.
When using Cocoapods SweeterSwift is available through all my project and is polluting my code completion box.
Certainly the stuff of SweeterSwift is super handy, but I don't want to use them to reduce dependencies from third party libraries.
This is a great library. I was wondering if it's possible to allow thumbs to cross over each other? Is this already a feature?
Allowing the left thumb go over the right thumb or allowing the right thumb go over the left thumb. Please let me know if this hasn't been implemented yet, thank you.
Hi,
Thanks for this good library.
I set a minimum and a maximum value to a horizontal slider with two thumbs.
I then set values for thumbs to the minimum and the maximum.
self.slider.minimumValue = 45 self.slider.maximumValue = 250 self.slider.snapStepSize = 1 self.slider.value = [45, 250]
When I start moving the dot to set a value, it starts from 0 which breaks the slider UI (the thumb stays stuck on the left until I move to 45 and starts moving after).
Moreover it allows the user to select a value I wanted to be forbidden.
Did I misunderstood something in the doc or is it a bug ?
Thanks.
Description of the problem:
Wrong upperBound when you snapStepSize is set
For example:
multiSlider.snapStepSize = 100.0
multiSlider.value = [40645.0, 81645.0]
This function - adjustValuesToStepAndLimits() define upperBound wrong.
For my case it will be transformed to [40645.0, 81600.0]
I expected to get the same values as input.
As a result when I get values after user selection I get cutting upper edge
**I am using the Multislider pod and when I choose to use two thumb and I tried to move the first thumb then right thumb automatically fluctuates **
[description]
Minimal project that reproduces the problem (so I'll be able to figure out how to fix it):
[github repo or a zipped project]
fileprivate
.Description of the problem:
I have a slider with two thumbs but i tried to set both properties and both of them are not taking effect, so they are still overlapping.
timeSlider.keepsDistanceBetweenThumbs = true
timeSlider.distanceBetweenThumbs = 50
Snap of my code :
timeSlider = MultiSlider()
timeSlider.frame = CGRect.init(x: 16, y: 0, width: UIScreen.main.bounds.width - 32, height: timeSliderContainer.frame.height)
timeSlider.minimumValue = 00.00 // default is 0.0
timeSlider.maximumValue = 23.5 // default is 1.0
timeSlider.snapStepSize = 0.5
timeSlider.value = [00.00, 23.5]
timeSlider.thumbCount = 2
timeSlider.outerTrackColor = AppConstants.Colors.General.cayan // outside of first and last thumbs
timeSlider.orientation = .horizontal // default is .vertical
timeSlider.tintColor = AppConstants.Colors.General.darkGray // color of track
timeSlider.trackWidth = 6
timeSlider.hasRoundTrackEnds = true
timeSlider.valueLabelPosition = .top
timeSlider?.showsThumbImageShadow = true
timeSlider.keepsDistanceBetweenThumbs = true
timeSlider.distanceBetweenThumbs = 50
timeSlider.addTarget(self, action: #selector(sliderChanged(slider:)), for: .valueChanged) // continuous changes
timeSlider.addTarget(self, action: #selector(sliderDragEnded(slider:)), for: . touchUpInside) // sent when drag ends
timeSliderContainer.addSubview(timeSlider)
// timeSliderContainer.addConstrainedSubview(timeSlider!, constrain: .leftMargin, .rightMargin, .bottomMargin)
// timeSliderContainer.layoutMargins = UIEdgeInsets(top: 0, left: 32, bottom: 0, right: 32)
timeSlider.thumbViews[0].image = UIImage(named: "min_time_icon")
timeSlider.thumbViews[1].image = UIImage(named: "max_time_icon")
timeSliderContainer.subviews.first?.removeFromSuperview()
I used these settings:
I slid all the thumbs to the bottom such that they can't be moved downwards anymore. Then I saw some weird values. From the value of the lowest thumb to the value of the highest thumb is the following values:
0.0, 0.999999999999986, 1.99009900990099, 2.98019801980197, 3.97029702970296
I would like the values to either be all 0s or rounded up to 0, 1, 2, 3, 4. Can you fix this?
How would I add more minimum distance between two thumbs? I would like there to be a least 5 points between them when they are pushed together.
Thanks!!!
Hi! Thank you for making this library! Very helpful.
I was wondering if it is possible to set a tintColor between your min and max value using only one thumb?
Hi @yonat ,
I'm getting the below error when I'm try to Run
this project on Xcode 10.1. Even I have clean the derived data and also changed to deployment target to 11.0
instead of 9.0
.
Module file's minimum deployment target is ios11.0 v11.0: /Users/ocsmobi2/Library/Developer/Xcode/DerivedData/MultiSliderDemo-heufnxwndnkrmbelfpkqwadwcxz/Build/Products/Debug-iphonesimulator/AvailableFeedback/AvailableHapticFeedback.swiftmodule/x86-64.swiftmodule
Thanks.
Description of the problem:
[description]
I have added a UIImage to each thumb in the MultiSlider but when I drag either the left thumb to the most minimum value or the right thumb to the most maximum value, it leaves a gap. So I thought if I increase the image size then I would solve that issue, what actually happened is the gap became bigger on both sides
Minimal project that reproduces the problem (so I'll be able to figure out how to fix it):
[github repo or a zipped project]
When adding MultiSlider
as a Swift Package into the project, it doesn't compile because of missing import UIKit
in extension files.
I changed that directly and it worked. So it would be awesome to have it on master
branch.
After installing the MultiSlider library by including pod 'MultiSlider' in my Podfile I receive the following error when attempting to set the class of a view to MultiSlider in my storyboard:
file:///Users/michellelane/ios-app/Spyderco/Spyderco/Settings/Storyboards/SettingsTermsAndConditions.storyboard: error: IB Designables: Failed to render and update auto layout status for UIViewController (sky-2X-3GA): dlopen(MultiSlider.framework, 1): Library not loaded: @rpath/AvailableHapticFeedback.framework/AvailableHapticFeedback
Referenced from: MultiSlider.framework
Reason: image not found
Any thoughts on why this might occur?
I'm trying to run the example source code in xocde version 9.4.1 but I get errors like this " 'Attribute' is not a member type of 'NSLayoutConstraint' , 'Relation' is not a member type of 'NSLayoutConstraint' " in it's miniLayout class.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.