All Projects → yonat → Multiselectsegmentedcontrol

yonat / Multiselectsegmentedcontrol

Licence: mit
UISegmentedControl remake that supports selecting multiple segments, vertical stacking, combining text and images.

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Multiselectsegmentedcontrol

Web Highlighter
✨ A no-runtime dependency lib for text highlighting & persistence on any website ✨🖍️
Stars: ✭ 373 (+106.08%)
Mutual labels:  selection
Bubble Picker
An easy-to-use animation which can be used for content picking for Android
Stars: ✭ 1,316 (+627.07%)
Mutual labels:  selection
Selectnextoccurrence
A Visual Studio Extension that selects the next occurrences of the current selection and adds multiple cursors for editing
Stars: ✭ 129 (-28.73%)
Mutual labels:  selection
Notie
🔔 a clean and simple notification, input, and selection suite for javascript, with no dependencies
Stars: ✭ 6,170 (+3308.84%)
Mutual labels:  selection
Insert Text At Cursor
Fast crossbrowser insertion of text at cursor position in a textarea / input
Stars: ✭ 49 (-72.93%)
Mutual labels:  selection
Selection
✨ Selection - A simple and lightweight library to add a visual way of selecting elements, just like on your Desktop. Zero dependencies. Full mobile and scroll support.
Stars: ✭ 1,371 (+657.46%)
Mutual labels:  selection
Dragselectrecyclerview
TouchListener that can be attached to any RecyclerView and handles multi selection for you
Stars: ✭ 371 (+104.97%)
Mutual labels:  selection
Deeputteranceaggregation
Modeling Multi-turn Conversation with Deep Utterance Aggregation (COLING 2018)
Stars: ✭ 171 (-5.52%)
Mutual labels:  selection
Ninaselectionview
Way to select your buttons.
Stars: ✭ 87 (-51.93%)
Mutual labels:  selection
Coinselect
An unspent transaction output (UTXO) selection module for bitcoin.
Stars: ✭ 121 (-33.15%)
Mutual labels:  selection
Share This
Medium-like text selection sharing without dependencies
Stars: ✭ 787 (+334.81%)
Mutual labels:  selection
Neataptic
🚀 Blazing fast neuro-evolution & backpropagation for the browser and Node.js
Stars: ✭ 1,027 (+467.4%)
Mutual labels:  selection
React Multi Select
A Multi Select component built with and for React
Stars: ✭ 111 (-38.67%)
Mutual labels:  selection
Selectpage
A simple style and powerful selector, including ajax remote data, autocomplete, pagination, tags, i18n and keyboard navigation features
Stars: ✭ 679 (+275.14%)
Mutual labels:  selection
Drag Select Recyclerview
👇 Easy Google Photos style multi-selection for RecyclerViews, powered by Kotlin and AndroidX.
Stars: ✭ 1,818 (+904.42%)
Mutual labels:  selection
Marklib
A small library to wrap serializable TextSelections.
Stars: ✭ 375 (+107.18%)
Mutual labels:  selection
React Selection
⬜️ Like the normal OS selection
Stars: ✭ 93 (-48.62%)
Mutual labels:  selection
React Native Selectable Text
Capture text selection and customize the action menu
Stars: ✭ 174 (-3.87%)
Mutual labels:  selection
Smenu
smenu started as a lightweight and flexible terminal menu generator, but quickly evolved into a powerful and versatile CLI selection tool for interactive or scripting use.
Stars: ✭ 1,906 (+953.04%)
Mutual labels:  selection
Sentaku
Utility to make sentaku (selection, 選択(sentaku)) window with shell command.
Stars: ✭ 117 (-35.36%)
Mutual labels:  selection

MultiSelectSegmentedControl

Swift Version Build Status License CocoaPods Compatible
Platform PRs Welcome

UISegmentedControl remake that supports selecting multiple segments, vertical stacking, combining text and images.

Features

  • [x] Single or multiple selection.
  • [x] Horizontal or vertical stacking.
  • [x] Can show text and images together.
  • [x] Use from either storyboard or code.
  • [x] UIAppearance support.

Usage

Very similar to UISegmentedControl, can be used as a drop-in replacement in most cases.

If you use Interface Builder, add a regular UIView and then set its class to MultiSelectSegmentedControl.

SwiftUI Usage

MultiSegmentPicker(
    selectedSegmentIndexes: $indexSet,
    items: ["One", "Two", image, [image2, "Text"], "Last"]
)

The properties mentioned below can be passed as arguments to the MultiSegmentPicker initializer, or used as view modifiers (e.g., .borderWidth(3)).

Creating Segments

Each segment can contain an image, a text, or both:

let multiSelect = MultiSelectSegmentedControl()
multiSelect.items = ["One", "Two", image, [image2, "Text"], "Last"]

Images are shown in full color (unlike UISegmentedControl). To make them render in the same tintColor as the control, use template mode:

multiSelect.items = [image1, image2, image3].map { $0.withRenderingMode(.alwaysTemplate) }

Selecting Segments

multiSelect.selectedSegmentIndexes = [1, 2, 4]

Or just single selection:

multiSelect.allowsMultipleSelection = false
multiSelect.selectedSegmentIndex = 3

Getting Selected Segments

let selectedIndices: IndexSet = multiSelect.selectedSegmentIndexes

Or to get the titles:

let titles: [String] = multiSelect.selectedSegmentTitles

Handling User Selection Changes

You can use standard target-action:

multiSelect.addTarget(self, action: #selector(selectionChanged), for: .valueChanged)

Or conform to the delegate protocol:

extension MyViewController: MultiSelectSegmentedControlDelegate {
    func multiSelect(_ multiSelectSegmentedControl: MultiSelectSegmentedControl, didChange value: Bool, at index: Int) {
        print("selected \(value) at \(index)")
    }
}

... and set the delegate:

multiSelect.delegate = self

Changing Appearance

Color:

multiSelect.tintColor = .green

Background Color (optional - use if background color should be different from tint color):

multiSelect.selectedBackgroundColor = .blue

Shape:

multiSelect.borderWidth = 3 // Width of the dividers between segments and the border around the view.
multiSelect.borderRadius = 32 // Corner radius of the view.

Stack the segments vertically:

multiSelect.isVertical = true

Stack each segment contents vertically when it contains both image and text:

multiSelect.isVerticalSegmentContents = true

Text styling:

multiSelect.setTitleTextAttributes([.foregroundColor: UIColor.yellow], for: .selected)
multiSelect.setTitleTextAttributes([.obliqueness: 0.25], for: .normal)

More label styling:

multiSelect.titleConfigurationHandler = {
    $0.numberOfLines = 0
    $0.lineBreakMode = .byWordWrapping
}

Installation

CocoaPods:

pod 'MultiSelectSegmentedControl'

Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/yonat/MultiSelectSegmentedControl", from: "2.3.5")
]

TODO

  • [ ] foreground color of selected segment should be/appear transparent
  • [ ] configure segment layoutMargins, stackView.spacing

Meta

@yonatsharon

https://github.com/yonat/MultiSelectSegmentedControl

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].