GithubHelp home page GithubHelp logo

kevinheader / multiselectsegmentedcontrol Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yonat/multiselectsegmentedcontrol

0.0 1.0 0.0 185 KB

Multiple-Selection UISegmentedControl

License: MIT License

Objective-C 93.83% Ruby 6.17%

multiselectsegmentedcontrol's Introduction

MultiSelectSegmentedControl

Multiple selection segmented control.

Build Status License CocoaPods Compatible Platform PRs Welcome

A subclass of UISegmentedControl that supports selecting multiple segments.

No need for images - works with the builtin styles of UISegmentedControl.

Features

  • Standard iOS look and feel.
  • Use from either storyboard or code.

Requirements

  • iOS 8.0+
  • Xcode 7.3

Installation

CocoaPods

You can use CocoaPods to install YourLibrary by adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!
pod 'MultiSelectSegmentedControl'

To get the full benefits import YourLibrary wherever you import UIKit

import UIKit
import MultiSelectSegmentedControl

Usage

Creating a MultiSelectSegmentedControl

In Interface Builder:

  1. Drag a UISegmentedControl into your storyboard.
  2. Set its class to MultiSelectSegmentedControl.
  3. Set an outlet for it, e.g., myMultiSeg.

In code:

self.myMultiSeg = [[MultiSelectSegmentedControl alloc] init];

Setting selected segments

myMultiSeg.selectedSegmentIndexes = [NSIndexSet indexSetWithIndex:1];

Getting selected segments

NSIndexSet *selectedIndices = myMultiSeg.selectedSegmentIndexes;

Or to get the titles:

NSArray *titles = myMultiSeg.selectedSegmentTitles;

Handling user selection changes

To be notified of changes to the control's value, make sure your ViewController conforms to the delegate protocol:

@interface MyViewController : UIViewController <MultiSelectSegmentedControlDelegate>

...and set the delegate, perhaps in your viewDidLoad method:

myMultiSeg.delegate = self;

Then override the delegate protocol method:

-(void)multiSelect:(MultiSelectSegmentedControl *)multiSelectSegmentedControl didChangeValue:(BOOL)selected atIndex:(NSUInteger)index {
	if (selected) {
		NSLog(@"Selected segment %u", index);
	} else {
		NSLog(@"Deselected segment %u", index);
	}
}

Meta

@yonatsharon

https://github.com/yonat/MultiSelectSegmentedControl

multiselectsegmentedcontrol's People

Contributors

yonat avatar raysarebest avatar stewartmacdonald avatar arennow avatar legranddamien avatar pws5068 avatar

Watchers

James Cloos 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.