Giter Site home page Giter Site logo

bharathbob / jmslider Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jasonmorrissey/jmslider

0.0 2.0 0.0 168 KB

A decorated iOS slider control to extend the functionality of a single button by sliding it. Created using only Core Graphics to make it easy to import into projects.

License: Other

Objective-C 100.00%

jmslider's Introduction

JMSlider

JMSlider is a sliding component that can be used to toggle three actions with a single button. For example, it can be used to allow for multiple actions at the end of lists/tables while keeping visual clutter to a minimum. The component is rendered entirely using Core Graphics so it does not require any additional images to be used in your projects.

How it looks

This is what JMSlider looks like out of the box, (or a video if you prefer):

Usage

A demo project is included in the repository so that you can give it a test drive. In brief, this is all you need to create the slider:

JMSlider *slider = [JMSlider sliderWithFrame:sliderFrame centerTitle:@"more" leftTitle:@"hide read" rightTitle:@"hide all" delegate:self];

By implementing the slider:didSelect: method, you will receive a callback when the tab selection changes.

Flexibility

JMSlider also supports the execution of blocks so that you can embed your logic inline, like this:

[slider setLeftExecuteBlock:^{ // do stuff after left option has been selected }];

Loading Indicator

The slider has a built-in activity indicator for convenience. To turn the activity indicator on:

[slider setLoading:YES];

The Demo project included also demonstrates how this can be used in your code.

Embedding in Table/ScrollViews

If you embed the slider in a tableView (e.g. in a UITableViewCell) be sure to call:

[tableView setCanCancelContentTouches:NO];

This will prevent the table/scrollView from scrolling vertically while the user is pressing down on the slider, which leads to a much better user experience.

Customisation

You can subclass any of the slider's internal components, and then implement any/all of the following methods in your delegate:

-(JMCenterView *)sliderCenterViewForSlider:(JMSlider *)slider

-(JMSideView *)sliderLeftViewForSlider:(JMSlider *)slider

-(JMSideView *)sliderRightViewForSlider:(JMSlider *)slider

-(JMSliderTrack *)sliderTrackViewForSlider:(JMSlider *)slider

For example, Alien Blue subclasses JMCenterView to draw a dark version of the toggle in Night Mode.

Acknowledgements

This project uses the UIView+Positioning and UIView+Size categories developed by the very talented Kevin O'Neill.

License

JMSlider is BSD licensed, so you can freely use it in commercial applications.

jmslider's People

Contributors

jasonmorrissey avatar

Watchers

James Cloos avatar Viswa Bharath avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.