All Projects → vascome → UIGradientSlider

vascome / UIGradientSlider

Licence: MIT license
GradientSlider is a UIControl subclass which is similar to UISlider, but with a linear gradient coloring the slider’s track. Useful for creating color pickers. Initially fork of https://github.com/jonhull/GradientSlider rewritten to Obj-C

Programming Languages

objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to UIGradientSlider

Gradientappbar
Gradient app bar for Flutter
Stars: ✭ 118 (+321.43%)
Mutual labels:  gradient
Webgradients
A curated collection of splendid gradients made in CSS3, .sketch and .PSD formats.
Stars: ✭ 2,197 (+7746.43%)
Mutual labels:  gradient
Swift Utils
A collection of handy swift utils
Stars: ✭ 253 (+803.57%)
Mutual labels:  gradient
Colorbands
Unity 3D's Gradient is a handy data type but comes with some limitations: for example you cannot set more than 8 color keys in its editor and RGB is the only color space available. ColorBand data type offers an alternative with less limitations. Creating ColorBands is fun and easy; they are stored as assets and can be accessed from code through an Evaluate method to get the color at time t, as for Gradient. RGB (or HSV) values are described by individual curves, allowing a better control over how the color function evolves between your points. Color bands are used in all kinds of applications including games, data visualization and other fields.
Stars: ✭ 137 (+389.29%)
Mutual labels:  gradient
Shift
Animate gradient changes with time or motion for iOS Swift
Stars: ✭ 165 (+489.29%)
Mutual labels:  gradient
Uigradient
A simple and powerful library for using gradient layer, image, color
Stars: ✭ 208 (+642.86%)
Mutual labels:  gradient
Gradientpathrenderer
Renders MKPolyline with a fancy multicoloured gradient fill
Stars: ✭ 112 (+300%)
Mutual labels:  gradient
andColorPicker
Color picker library for Android
Stars: ✭ 233 (+732.14%)
Mutual labels:  colorpicker
Xamarin.forms.backgroundkit
🔨 A powerful Kit for customizing the background of Xamarin.Forms views
Stars: ✭ 167 (+496.43%)
Mutual labels:  gradient
Rhplaceholder
Show pleasant loading view for your users 😍
Stars: ✭ 238 (+750%)
Mutual labels:  gradient
Gradstop
JavaScript micro library to generate gradient color stops 🏳️‍🌈
Stars: ✭ 144 (+414.29%)
Mutual labels:  gradient
Mkgradientview
🌈 Highly customizable Core Graphics based gradient view for iOS
Stars: ✭ 159 (+467.86%)
Mutual labels:  gradient
Dynamiccolor
Yet another extension to manipulate colors easily in Swift and SwiftUI
Stars: ✭ 2,677 (+9460.71%)
Mutual labels:  gradient
React Native Css Gradient
React Native css gradients - react-native-linear-gradient with css gradient support
Stars: ✭ 129 (+360.71%)
Mutual labels:  gradient
css-studies
🎨 Aplicação com interface baseada em Neumorphism + Geração de códigos CSS para Gradientes e Bordas + Visualização instantânea.
Stars: ✭ 33 (+17.86%)
Mutual labels:  gradient
Shapy
Shapy is a CSS gradient editor that lets you size, position and layer CSS gradients on a single div element.
Stars: ✭ 115 (+310.71%)
Mutual labels:  gradient
Ocskeleton
[OCSkeleton] - Make your loading view a little difference.
Stars: ✭ 184 (+557.14%)
Mutual labels:  gradient
Rainblur-Landing-Page
Tailwind CSS Starter Template - Rainblur Landing Page (dark)
Stars: ✭ 112 (+300%)
Mutual labels:  gradient
Weather-SwiftUI
A weather app that uses the Dark Sky API built using SwiftUI! Get the current weather for a particular location and check out the 5-day forecast!
Stars: ✭ 107 (+282.14%)
Mutual labels:  gradient
Unity Uigradient
A UI gradient effect script for Unity
Stars: ✭ 231 (+725%)
Mutual labels:  gradient

GradientSlider

alt tag

GradientSlider is a UIControl subclass which is similar to UISlider, but with a linear gradient coloring the slider’s track. Useful for creating color pickers. It is written in Swift 2 and requires it.

Features

  • Easily define a gradient by setting the min & max (i.e. left & right) colors
  • Rainbow gradients (with customizable saturation & brightness) for making Hue selection sliders
  • IBDesignable/Inspectable for direct use within Interface Builder
  • Add an icon or color to the slider thumb
  • Min/Max images (similar to UISlider)
  • Both Target/Action and Block-based callbacks
  • Customizable track thickness
  • Customizable track border and thumb size
  • Looks like UISlider by default, so they can be intermixed in the UI

Installation

Drag the “UIGradientSlider” file into your Xcode project

Usage via Interface Builder

Drag a custom view into your storyboard and change it’s class to “UIGradientSlider”. Use the attributes inspector to optionally set the slider’s basic properties:

  • min/max color
  • hasRainbow (Note: the min color’s saturation & brightness are used)
  • value
  • minimum/maximum value
  • minimum/maximum images
  • thickness
  • thumbIcon

Setting the Track Gradient Programmatically

Min/Max Color

The track displays a linear gradient with the minColor corresponding to the minimumValue and the maxColor corresponding to the maximumValue.

slider.minValue = [UIColor blueColor];
slider.maxValue = [UIColor orangeColor];

img alt

Rainbow

When the hasRainbow property is set to true, the track displays a rainbow gradient which moves around the color wheel (starting and ending with red). The saturation & brightness are both pulled from the color in minValue.

slider.minValue = [UIColor blueColor]; //This has full saturation & brightness
slider.hasRainbow = YES;

img alt

Responding to User Interaction

Target/Action

As a UIControl subclass, the traditional target/action approach is fully supported. The slider will send TouchDown, ValueChanged, and TouchUpInside actions. If the continuous property is set to true (which it is by default), then the slider will send ValueChanged actions as the slider changes, otherwise a ValueChanged action is only sent when the user releases the slider.

ActionBlock

The slider will also call it’s actionBlock when its value is changed. If the continuous property is set to true (which it is by default), then the slider will call its actionBlock as the slider changes, otherwise it will only call it once when the slider is released. The actionBlock property takes a closure which takes 2 parameters: The slider being changed and the new value, and has no return value. It’s signature is: (UIGradientSlider,CGFloat)->()

Images showing the effect of dragging the hue slider img alt

img alt

Customizing the Track

Besides the background gradient, the track is customizable in several ways using the following properties:

  • thickness:CGFloat This sets the track’s thickness. The default value is 2pts
  • borderColor:UIColor This sets the color of the track’s border. The default value is black.
  • borderWidth:CGFloat This sets the width of the track’s border. The default value is 0 (i.e. no border).
  • minimumValueImage:UIImage This places an image to the left of the track. Setting it to nil removes any image which is there. The default value is nil (i.e. no image).
  • maximumValueImage:UIImage This places an image to the right of the track. Setting it to nil removes any image which is there. The default value is nil (i.e. no image).
  • trackBorderWidth:CGFloat This sets the border width for track(slider).
  • trackBorderColor:UIColor This sets the border color for track(slider).

Customizing the Thumb

The thumb can be resized, given a custom color or an icon (it can not have both a color and an icon at the same time). To customize the thumb, use the following properties:

  • thumbSize:CGFloat This sets the diameter of the thumb. Note: Resizing the thumb may change the slider’s intrisicContentSize. The default is 28.0 pts.
  • thumbColor:UIColor This sets the color displayed by the thumb. When the thumb has an associated icon, the color is automatically set to clearColor, and setting a new color removes the icon. The default value is White.
  • thumbIcon:UIImage This sets the image to display inside the slider’s thumb. Setting an image automatically removes the thumbColor, and setting a color removes the icon. The default value is nil (i.e. no image)
  • thumbBorderColor:UIColor This sets the border color for thumb.
  • thumbBorderWidth:CGFloat This sets the border width for thumb.

License

The MIT License (MIT)

Copyright (c) 2017 Vasily Popov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].