Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

wishchen/DOFavoriteButton

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DOFavoriteButton

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

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.

License

This software is released under the MIT License.

About

Cute Animated Button written in Swift.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 72.1%
  • Shell 21.8%
  • Ruby 3.0%
  • Objective-C 1.7%
  • C 1.4%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.