Giter Club home page Giter Club logo

tbmultiappearancebutton's Introduction

TBMultiAppearanceButton

Cocoapod compatible Carthage compatible MIT License

Swift framework to configure and switch between multiple appearances of a UIButton, courtesy of Talking Bibles International and Clay Smith

USAGE

This framework adds a TBMultiAppearanceButton subclass of UIButton. This new class allows for switching between multiple appearances of the button, each with its own full complement of UIButton core properties. Each appearance may be configured for all UIControlStates, including highlight and selected.

struct PlayerControlAppearance: TBControlAppearanceType {
  let rawValue: Int

  init(rawValue: Int) { self.rawValue = rawValue }

  static let Play = PlayerControlAppearance(rawValue: 1)
  static let Pause = PlayerControlAppearance(rawValue: 2)
}

let button = TBMultiAppearanceButton<PlayerControlAppearance>(frame: CGRectMake(0, 0, 100, 100))

button.setTitle("Play", forAppearance: .Play, andState: .Normal)
button.setTitle("Play", forAppearance: .Pause, andState: .Highlighted)

button.setBackgroundImage(UIImage.imageWithColor(UIColor.blueColor()), forAppearance: .Play, andState: .Normal)
button.setBackgroundImage(UIImage.imageWithColor(UIColor.lightGrayColor()), forAppearance: .Play, andState: .Highlighted)

// Later... select the Play appearance
button.activateAppearance(.Play)

// Even later... select the Pause appearance
button.activateAppearance(.Pause)

INSTALL

This project is compatible with Cocoapods and Carthage. (These instructions assume that your chosen method is already installed.)

Cocoapods

Add pod 'TBMultiAppearanceButton' to your target. Since this is a Swift dynamic framework, you must also tell Cocoapods to use_frameworks! instead of static libraries.

platform :ios, '9.0' # or, :osx, '10.10'
use_frameworks!

target 'YourProject' do
pod 'TBMultiAppearanceButton', '~> 1.1.0'
end

Carthage

Add github "TalkingBibles/TBMultiAppearanceButton" ~> 1.1.0 to your Cartfile and run carthage bootstrap. This builds frameworks for Mac and iOS targets.

> echo 'github "TalkingBibles/TBMultiAppearanceButton" ~> 1.0.0' >> Cartfile
> carthage bootstrap

TODO

  • Improve tests and add continuous integration testing
  • Add better usage documentation

License

See License

tbmultiappearancebutton's People

Contributors

stphnclysmth avatar

Watchers

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