Giter Club home page Giter Club logo

lunsegmentedcontrol's Introduction

LUNSegmentedControl

Crafted in LunApps

Please check this article on our blog.

Purpose

LUNSegmentedControl is control designed to let developers use segmented control with custom appearance, customizable interactive animation and other pretty things like gradient for states and shadow.

Supported OS & SDK Versions

  • Supported build target - iOS 8.0

ARC Compatibility

LUNSegmentedControl requires ARC.

Installation

To use the LUNSegmentedControl in your app, just drag the LUNSegmentedControl folder into your project.

Or you can use CocoaPods

pod 'LUNSegmentedControl'

Usage

Add a UIView and change its class to LUNSegmentedControl. Then you need to set its data source (either from the storyboard or programmaticaly). Implement the data source method that returns the segment count:

- (NSInteger)numberOfStatesInSegmentedControl:(LUNSegmentedControl *)segmentedControl;

Now implement one of the Data Source methods so you can set either a string, an attributed string or a view to be displayed in every segment.

- (NSString *)segmentedControl:(LUNSegmentedControl *)segmentedControl titleForStateAtIndex:(NSInteger)index;
- (NSAttributedString *)segmentedControl:(LUNSegmentedControl *)segmentedControl attributedTitleForStateAtIndex:(NSInteger)index;
- (UIView *)segmentedControl:(LUNSegmentedControl *)segmentedControl viewForStateAtIndex:(NSInteger)index;

If necessary, you can set a string, an attributed string or a view for the selected state for each segment with the help of following Data Source methods:

- (NSString *)segmentedControl:(LUNSegmentedControl *)segmentedControl titleForSelectedStateAtIndex:(NSInteger)index;
- (NSAttributedString *)segmentedControl:(LUNSegmentedControl *)segmentedControl attributedTitleForSelectedStateAtIndex:(NSInteger)index;
- (UIView *)segmentedControl:(LUNSegmentedControl *)segmentedControl viewForSelectedStateAtIndex:(NSInteger)index;

After that you can set the following parameters (either from the storyboard or programmaticaly) in order to change the way your control looks:

@property (nonatomic, assign) IBInspectable CGFloat cornerRadius;

In case you want to customize corner radius of the control.

@property (nonatomic, strong) IBInspectable UIColor *textColor;

Change that if you want to customize text color for titles of unselected segments.

@property (nonatomic, strong) IBInspectable UIColor *selectedStateTextColor;

It is used to change the text color of the title for the selected segment.

@property (nonatomic, strong) IBInspectable UIColor *selectorViewColor;

That’s how you change the color of selection itself.

In addition, you can set a color (or a number of colors to get a gradient) for each segment, left and right bounces with the help of the following data source methods:

- (NSArray <UIColor *> *)segmentedControl:(LUNSegmentedControl *)segmentedControl gradientColorsForStateAtIndex:(NSInteger)index;
- (NSArray <UIColor *> *)segmentedControl:(LUNSegmentedControl *)segmentedControl gradientColorsForBounce:(LUNSegmentedControlBounce)bounce;

If you want to recieve notifications about position changes, set control's delegate.

Check out the documentation to find description for more methods and properties you may use.

License

Usage is provided under the MIT License

lunsegmentedcontrol's People

Contributors

seland avatar

Watchers

James Cloos avatar Lucas Farah 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.