Giter Club home page Giter Club logo

twicketsegmentedcontrol's Introduction

TwicketSegmentedControl

This is a fork of a fork of the original that works with Swift 5.0

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', :git => 'https://github.com/thatmarcel/TwicketSegmentedControl'

• Carthage

github "thatmarcel/TwicketSegmentedControl"

• Manually

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

twicketsegmentedcontrol's People

Contributors

polqf avatar thatmarcel avatar poeticpete avatar heinst 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.