Custom UISegmentedControl replacement for iOS, written in Swift

Overview

TwicketSegmentedControl

Carthage compatible

Custom UISegmentedControl replacement for iOS, written in Swift, used in the Twicket app.

It handles the inertia of the movement, so you can “throw” the selector from one side to the other.

Take a look at the design by @dsaltaren on Dribbble

Features:

  • Drag and Tap gesture
  • Movement animation
  • IB compatible
  • Customizable colors

How to use it:

You can either create it using Interface Builder, or by code.

Whenever the segmented control is instantiated, you'll have to tell it which are going to be the segments it will have:

	let titles = ["First", "Second", "Third"]
	segmentedControl.setSegmentItems(titles)

Every time you use this function, the control is redrawn.

If you want to manually move to an index:

	segmentedControl.move(to: 2)

Keep in mind that the first segment index is 0

To listen to changes on the selected index you just need to set yourself as delegate:

	segmentedControl.delegate = self

And you'll get notified with the following interface:

	func didSelect(_ segmentIndex: Int)

One last thing to mention, even if you set a different outer frame, its contentView height will always be 40.

Customization:

You can customize the segmented control through the following properties:

defaultTextColor: UIColor - Text color for unselected segments

highlightTextColor: UIColor - Text color for selected segment

segmentsBackgroundColor: UIColor - Background color for unselected segments

sliderBackgroundColor: UIColor - Background color for selected segment

isSliderShadowHidden: Bool - Boolean to decide if the slider should have shadow

Installation:

• CocoaPods

use_frameworks!

pod 'TwicketSegmentedControl'

• Carthage

github "twicketapp/TwicketSegmentedControl"

• Manually

To manually add TwicketSegmentedControl to your project you just need to copy the Source folder files.

Comments
  • func didSelect(_ segmentIndex: Int) Not working for me.

    func didSelect(_ segmentIndex: Int) Not working for me.

    Hi great framework you have made. I have installed the TwicketSegmentedControl and used the delegate after the class declaration. I use the func didSelect(_ segmentIndex: Int) but it does not react to changes. Can you update your example with the implementation please?

    opened by sashalondon 2
  • segmentsBackgroundColor cannot be changed

    segmentsBackgroundColor cannot be changed

    Looks like this will never be set to a new value as its always set to background color in setter

    open var segmentsBackgroundColor: UIColor = Palette.segmentedControlBackgroundColor {
            didSet {
                backgroundView.backgroundColor = backgroundColor
            }
        }
    
    opened by roopeshmittal 1
  • DidSelect TableView.reloaddata()

    DidSelect TableView.reloaddata()

    Everything is working on DidSelect, but when I call tableview.reload the tableview reloads with the correct data but the segmented control stays on index[0] even though the print says index[1]. I only have two titles on the segementedControl.

    When I select index[1] the segment jumps to it and immediately switches back to index[0].

    opened by Manny7311 1
  • Issue with element interaction with segmented control

    Issue with element interaction with segmented control

    Everything works in regards to the segmented control displaying the correct view (aka container). My issue is that in the container view, user can not interact with any elements as simple as text fields, uipicker, etc... basically anything but Images and Labels!?

    opened by famictech2000 0
  • Bug: selected segment background color persistence

    Bug: selected segment background color persistence

    Thanks for your awesome library! I'm running into a bug where the selected segment background color persists sometimes after moving it to another segment (see below). Please help!

    img_0325

    Code for implementation is below: let segmentedControlTitles = ["Assistant","Itinerary","Chat"] segmentedControl = TwicketSegmentedControl(frame: CGRect(x: UIScreen.main.bounds.width / 2 - 135, y: 20, width: 270, height: 40)) segmentedControl?.setSegmentItems(segmentedControlTitles) segmentedControl?.delegate = self segmentedControl?.segmentsBackgroundColor = UIColor.clear segmentedControl?.isSliderShadowHidden = false segmentedControl?.backgroundColor = .clear // This is important!

    opened by mwurm93 0
  • Add isSliderShadowHidden to be able to hide slider's shadow

    Add isSliderShadowHidden to be able to hide slider's shadow

    Following with @leminhtuan2015 's petition related to a way to disable the slider's shadow, there's now a new property called isSliderShadowHidden that handles exactly that.

    screen shot 2017-02-01 at 00 35 27

    Fixes #7

    opened by polqf 0
  • White square around segment control ?

    White square around segment control ?

    Could I remove or change the white color behind the segment control ? Thanks in advance for great library

    screen shot 2016-12-13 at 8 23 27 pm

    *UPDATE : I managed to do it by setting segmentedControl.backroundColor to clear color

    opened by fadylateef 0
  • Long segment title is not showing completely

    Long segment title is not showing completely

    If one of the segment titles is too long, then it is not showing complete text, is there any way we can overcome that or have an alternative to resolve it. For reference, I have attached a screenshot.

    Any help would be appreciated. screenshot at jan 31 19-40-09

    opened by simform-solutions 0
Releases(0.1.2)
Owner
Pol Quintana
iOS Architect @GetStream
Pol Quintana
A highly customizable drop-in replacement for UISegmentedControl.

HMSegmentedControl A highly customizable drop-in replacement for UISegmentedControl, used by more than 22,000 apps, including TikTok, PayPal, Imgur an

Hesham Abd-Elmegid 3.9k Dec 21, 2022
UISegmentedControl remake that supports selecting multiple segments, vertical stacking, combining text and images.

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

Yonat Sharon 286 Dec 15, 2022
MacSegmentedControl - UISegmentedControl on macOS

Mac Segmented Control An implementation of iOS' UISegmentedControl on macOS. Add

Jeff Dlouhy 0 Dec 30, 2021
A segmented control with custom appearance and interactive animations. Written in Swift 3.0.

SJFluidSegmentedControl About If you are bored with using the default UISegmentedControl, this might save your day. SJFluidSegmentedControl is a custo

Sasho Jadrovski 904 Dec 30, 2022
AKASegmentedControl is a fully customizable Segmented Control for iOS

#AKASegmentedControl AKASegmentedControl is a fully customizable Segmented Control for iOS ##Preview ##Usage Installation CocoaPods You can use CocoaP

Ali Karagoz 389 Sep 1, 2022
A customizable Segmented Control for iOS. Supports text and image.

YUSegment 中文文档 A customizable segmented control for iOS. Features Supports both (Attributed)text and image Supports show separator Supports hide indic

YyGgQq 112 Jun 10, 2022
An easy to use, customizable replacement for UISegmentedControl & UISwitch.

BetterSegmentedControl BetterSegmentedControl is an easy to use, customizable replacement for UISegmentedControl and UISwitch written in Swift. Featur

George Marmaridis 2k Dec 30, 2022
A highly customizable drop-in replacement for UISegmentedControl.

HMSegmentedControl A highly customizable drop-in replacement for UISegmentedControl, used by more than 22,000 apps, including TikTok, PayPal, Imgur an

Hesham Abd-Elmegid 3.9k Dec 21, 2022
A replacement for as which runs in constant time instead of O(n) when the conformance is not satisfiedA replacement for as which runs in constant time instead of O(n) when the conformance is not satisfied

ZConform A replacement for as? which runs in constant time instead of O(n) when the conformance is not satisfied. How it works ZConform does a one-tim

Emerge Tools 20 Aug 4, 2022
UISegmentedControl remake that supports selecting multiple segments, vertical stacking, combining text and images.

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

Yonat Sharon 286 Dec 15, 2022
UISegmentedControl remake that supports selecting multiple segments, vertical stacking, combining text and images.

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

Yonat Sharon 286 Dec 15, 2022
MacSegmentedControl - UISegmentedControl on macOS

Mac Segmented Control An implementation of iOS' UISegmentedControl on macOS. Add

Jeff Dlouhy 0 Dec 30, 2021
CollectionViewSegmentedControl - Scrollable UISegmentedControl built using a UICollectionView

CollectionViewSegmentedControl Installation CocoaPods Download CocoaPods Run 'Po

James Sedlacek 7 Nov 24, 2022
The missing UIKit component. A scrollable alternative to UISegmentedControl

Requirements iOS 15.0 and higher Installation Swift Package Manager: dependencies: [ .package(url: "https://github.com/hugo-pivaral/UITabControl.git

Hugo Pivaral 11 Nov 18, 2022
Replacement for Apple's Reachability re-written in Swift with closures

Reachability.swift Reachability.swift is a replacement for Apple's Reachability sample, re-written in Swift with closures. It is compatible with iOS (

Ashley Mills 7.7k Jan 1, 2023
A SlackTextViewController replacement written in Swift for the iPhone X.

Installation Just add MessageViewController to your Podfile and install. Done! pod 'MessageViewController' Setup You must subclass MessageViewControll

GitHawk 1.7k Jan 4, 2023
A pixel perfect replacement for UITableView section index, written in Swift

MYTableViewIndex MYTableViewIndex is a re-implementation of UITableView section index. This control is usually seen in apps displaying contacts, track

Yury 520 Oct 27, 2022
:octocat: AdaptiveController is a 'Progressive Reduction' Swift UI module for adding custom states to Native or Custom iOS UI elements. Swift UI component by @Ramotion

ADAPTIVE TAB BAR 'Progressive Reduction' module for adding custom states to Native or Custom UI elements. We specialize in the designing and coding of

Ramotion 2k Nov 9, 2022
null 13 Oct 28, 2022
Linenoise-Swift A pure Swift implementation of the Linenoise library. A minimal, zero-config readline replacement.

Linenoise-Swift A pure Swift implementation of the Linenoise library. A minimal, zero-config readline replacement. Supports Mac OS and Linux Line edit

Andy Best 114 Dec 14, 2022