GithubHelp home page GithubHelp logo

simonbromberg / bettersegmentedcontrol Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gmarm/bettersegmentedcontrol

0.0 2.0 0.0 2.84 MB

An easy to use, customizable replacement for UISegmentedControl & UISwitch.

License: MIT License

Ruby 2.52% Swift 97.48%

bettersegmentedcontrol's Introduction

BetterSegmentedControl

Version Carthage compatible License Platform

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

Demo

Features

  • Can be used as a segmented control or switch
  • Plethora of customizable options from colors to insets and radii
  • Use icons as segments, or add your own custom segments
  • Designable straight in Interface Builder
  • Customizable behavior
  • Right to left languages support

Requirements

  • iOS 9.0+
  • Xcode 8+

Installation

CocoaPods

BetterSegmentedControl is available through CocoaPods. To install it, simply add the following line to your Podfile:

# Swift 5
pod 'BetterSegmentedControl', '~> 1.2'

# Swift 4
pod 'BetterSegmentedControl', '1.0'

# Swift 3 / Objective-C
pod 'BetterSegmentedControl', '0.8'

Carthage

If you prefer using Carthage, simply add BetterSegmentedControl to your Cartfile:

# Swift 5
github "gmarm/BetterSegmentedControl" ~> 1.2

# Swift 4
github "gmarm/BetterSegmentedControl" 1.0

# Swift 3 / Objective-C
github "gmarm/BetterSegmentedControl" 0.8

Manually

If you prefer not to use CocoaPods or Carthage, you can integrate BetterSegmentedControl into your project manually.

Usage

let control = BetterSegmentedControl(
    frame: CGRect(x: 0, y: 0, width: 300, height: 44),
    segments: LabelSegment.segments(withTitles: ["One", "Two", "Three"],
    normalFont: UIFont(name: "HelveticaNeue-Light", size: 14.0)!,
    normalTextColor: .lightGray,
    selectedFont: UIFont(name: "HelveticaNeue-Bold", size: 14.0)!,
    selectedTextColor: .white),
    index: 1,
    options: [.backgroundColor(.darkGray),
              .indicatorViewBackgroundColor(.blue)])
control.addTarget(self, action: #selector(ViewController.controlValueChanged(_:)), for: .valueChanged)
view.addSubview(control)

You can find different ways of using it (such as by designing it in a Storyboard file) in the example project. To run the example project, clone the repo, and run pod install from the Example directory first.

Contribution

Feel free to Fork, submit Pull Requests or send me your feedback and suggestions! Please make sure that tests are passing before submitting a new Pull Request.

Known Issues

  • CocoaPods version 1.5+ breaks IBDesignable support. If you need IBDesignable support stick to CocoaPods version 1.4 for now.

Author

George Marmaridis

License

BetterSegmentedControl is available under the MIT license. See the LICENSE file for more info.

bettersegmentedcontrol's People

Contributors

gmarm avatar calissendorff avatar lukedurrant avatar poissonballon avatar borut-t avatar amorde avatar ewg777 avatar janebond92 avatar simonbromberg avatar

Watchers

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