GithubHelp home page GithubHelp logo

lingling2012 / dofavoritebutton Goto Github PK

View Code? Open in Web Editor NEW

This project forked from okmr-d/dofavoritebutton

0.0 2.0 0.0 68 KB

Cute Animated Button written in Swift.

License: MIT License

Swift 93.81% Objective-C 2.48% Ruby 3.71%

dofavoritebutton's Introduction

DOFavoriteButton

Carthage compatible Version Platform License

Cute Animated Button written in Swift. It could be just right for favorite buttons! Demo

Requirements

  • iOS 7.0+
  • Swift 1.2

Installation

Carthage

Add the following line to your Cartfile:

github "okmr-d/DOFavoriteButton"

CocoaPods

Add the following line to your Podfile:

pod 'DOFavoriteButton'

Manual

Just drag DOFavoriteButton.swift to your project.

How to use

1. Add a flat icon image

Flat Icon Image

2. Create a button

・By coding
let button = DOFavoriteButton(frame: CGRectMake(0, 0, 44, 44), image: UIImage(named: "star.png"))
self.view.addSubview(button)
・By using Storyboard or XIB
  1. Add Button object and set Custom Class DOFavoriteButton
    via Storyboard

  2. Connect Outlet
    connect outlet

3. Add tapped function

button.addTarget(self, action: Selector("tapped:"), forControlEvents: .TouchUpInside)
func tapped(sender: DOFavoriteButton) {
    if sender.selected {
        // deselect
        sender.deselect()
    } else {
        // select with animation
        sender.select()
    }
}

Customize

You can change button color & animation duration:

button.imageColorOff = UIColor.brownColor()
button.imageColorOn = UIColor.redColor()
button.circleColor = UIColor.greenColor()
button.lineColor = UIColor.blueColor()
button.duration = 3.0 // default: 1.0

Result:
Customize

DEMO

There is a demo project added to this repository, so you can see how it works.

Credit/Inspiration

DOFavoriteButton was inspired by Twitter's iOS App.

License

This software is released under the MIT License.

dofavoritebutton's People

Contributors

alexruperez avatar bitdeli-chef avatar chrisballinger avatar eugenpirogoff avatar jakesc avatar kylebshr avatar okmr-d avatar skywinder avatar tupakapoor avatar

Watchers

 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.