Git Product home page Git Product logo

fave-button's Introduction

FaveButton

CocoaPods CocoaPods Carthage compatible codebeat badge Build Status

Favorite Animated Button written in Swift

preview

Requirements

  • iOS 8.0+
  • Xcode 7.3

Installation

For manual instalation, drag Source folder into your project.

os use CocoaPod adding this line to you Podfile:

pod 'FaveButton', '~> 1.2.1' swift 2.2

pod 'FaveButton', '~> 2.0.3' swift 3

for Carthage users, add this line to you Cartfile

github "xhamr/fave-button"

Usage

With storyboard or xib files

  1. Create a Button that inherits from FaveButton

  2. Add Image for a Normal state

  3. Set the IBOutlet delegate property to a subclass of FaveButtonDelegate

  4. Optional manipulate porperties to change button settings

@IBInspectable public var normalColor:     UIColor
@IBInspectable public var selectedColor:   UIColor
@IBInspectable public var dotFirstColor:   UIColor
@IBInspectable public var dotSecondColor:  UIColor
@IBInspectable public var circleFromColor: UIColor
@IBInspectable public var circleToColor:   UIColor
  1. Optional respond to delegate methods
func faveButton(faveButton: FaveButton, didSelected selected: Bool)    
func faveButtonDotColors(faveButton: FaveButton) -> [DotColors]?     

In Code

let faveButton = FaveButton(
    frame: CGRect(x:200, y:200, width: 44, height: 44),
    faveIconNormal: UIImage(named: "heart")
)
faveButton.delegate = self
view.addSubview(faveButton)

Manipulating dot colors

If you want differents colors for dots like Twitter’s Heart Animation use the delegate method for the button you want.

func faveButtonDotColors(_ faveButton: FaveButton) -> [DotColors]?{
	if faveButton == myFaveButton{
		// return dot colors
	}
	return nil
}

in FaveButtonDemo you will find a set of color to cause dots appear like this:

preview

Credits

FaveButton was inspired by Twitter’s Like Heart Animation within their App

Licence

FaveButton is released under the MIT license.

fave-button's People

Contributors

janselv avatar jomnius avatar

Watchers

 avatar

Forkers

jonasman

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.