Latest 1.2.0
Homepage https://github.com/tbaranes/DOButton
License MIT
Platforms ios 8.0, requires ARC
Authors

CI Status
Language
CocoaPods Compatible
Carthage compatible
Platform
License

Note: This project is a maintained clone of the original DOFavoriteButton.

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

Requirements

  • iOS 7.0+
  • Swift 1.2

Installation

CocoaPods

Add the following line to your Podfile:

pod 'DOButton'

Carthage

Add the following line to your Cartfile:

github "tbaranes/DOButton"

Manual

Just drag DOButton.swift to your project.

How to use

1. Add a flat icon image

Flat Icon Image

2. Create a button

・By coding
let button = DOButton(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 DOButton
    via Storyboard

  2. Connect Outlet
    connect outlet

3. Add tapped function

button.addTarget(self, action: Selector("tapped:"), forControlEvents: .TouchUpInside)
func tapped(sender: DOButton) {
    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

DOButton was inspired by Twitter’s iOS App.

License

This software is released under the MIT License.

Latest podspec

{
    "name": "DOButton",
    "version": "1.2.0",
    "summary": "Cute Animated Button written in Swift. It could be just right for favorite buttons!",
    "description": "Cute Animated Button written in Swift. It could be just right for favorite buttons! Maintained clone of https://github.com/okmr-d/DOFavoriteButton",
    "homepage": "https://github.com/tbaranes/DOButton",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Tom Baranes": "[email protected]"
    },
    "source": {
        "git": "https://github.com/tbaranes/DOButton.git",
        "tag": "1.2.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Source/*.swift"
}

Pin It on Pinterest

Share This