Need help with DOFavoriteButton?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

okmr-d
3.5K Stars 307 Forks MIT License 40 Commits 35 Opened issues

Description

Cute Animated Button written in Swift.

Services available

!
?

Need anything else?

Contributors list

# 67,698
Swift
Ruby
16 commits
# 94,999
Swift
cocoapo...
swift-p...
propert...
2 commits
# 120,897
Swift
Objecti...
iOS
walkthr...
2 commits
# 231,711
Swift
Objecti...
1 commit
# 229,243
Swift
carthag...
Objecti...
cocoapo...
1 commit
# 5,977
Objecti...
iphone
otr
sqlciph...
1 commit
# 4,760
cocoapo...
Apache ...
carthag...
swift-f...
1 commit
# 11,943
autohot...
ahk
bitwise...
Nette
1 commit
# 58,926
Linux
Swift
swift-l...
swift-e...
1 commit
# 81,572
Objecti...
Swift
swift-f...
userdef...
1 commit

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:

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

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.