Revamped Download Button. It's kinda a reverse engineering of Netflix's app download button.

Overview

NFDownloadButton

iOS watchOS tvOS macOS

Platform CocoaPods Carthage Compatible

Revamped Download Button

Requirements

  • iOS 8.0+
  • Swift 4.2+
  • Xcode 10.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1.0+ is required to build NFDownloadButton 0.0.6+.

To integrate NFDownloadButton into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'NFDownloadButton', '~> 0.0.6'

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate NFDownloadButton into your Xcode project using Carthage, specify it in your Cartfile:

github "LeonardoCardoso/NFDownloadButton" ~> 0.0.6

Manually

If you prefer not to use either of the aforementioned dependency managers, you can integrate NFDownloadButton into your project manually.

Usage

You can use a NFDownloadButton on Storyboards or, if you want to do it programatically, you can create it just like you create a UIButton:

let downloadButton = NFDownloadButton(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
self.parentView.addSubview(downloadButton)

NFDownloadButton has four states:

State 1: To Download State 2: Will Download State 3: Ready to Download State 4: Downloaded
first second third fourth

You can switch between states by just doing as following:

self.downloadButton.downloadState = .toDownload || .willDownload || .readyToDownload || .downloaded

When the button is in .readyToDownload state, the button will wait for your to upload its progress. You can do it like this:

self.downloadButton.downloadPercent = 0.5

When this value reaches 1.0, then downloadState is automatically changed to .downloaded.

Downloaded by default

You can select the button as downloaded by default. All states will be overridden by Downloaded state and no animation will be performed. To do so, just add isDownloaded in its constructor, or set it up whenever you want.

NFDownloadButton(frame: CGRect(x: 0, y: 0, width: 50, height: 50), isDownloaded: true)
downloadButton.isDownloaded = true

Style

NFDownloadButton has four different styles of devices: iOS, watchOS, tvOS, macOS. Thus you can customize your final result. This option is only available on constructor.

NFDownloadButton(frame: CGRect(x: 0, y: 0, width: 50, height: 50), isDownloaded: true,
    style: .iOS)
iOS watchOS tvOS macOS
iOS watchOS tvOS macOS

Palette

You also can customize the colors of the button on its constructor.

NFDownloadButton(
    frame: wrapView.frame,
    isDownloaded: true,
    style: .iOS,
    palette: Palette(
        initialColor: UIColor?,
        rippleColor: UIColor?,
        buttonBackgroundColor: UIColor?,
        downloadColor: UIColor?,
        deviceColor: UIColor?
    )
)

palette

Delegate

You can watch changes of state by implementing the protocol:

protocol NFDownloadButtonDelegate {

    func stateChanged(button: NFDownloadButton, newState: NFDownloadButtonState)

}

Storyboard

Last but not least, you can customize NFDownloadButton properties right from Interface Builder or Storyboards.

storyboard

License

NFDownloadButton is released under the MIT license. See LICENSE for details.

Follow me for the latest updates

You might also like...
iOS Pod for a Soft UI (Neumorphic) Button for UIKit written in Swift
iOS Pod for a Soft UI (Neumorphic) Button for UIKit written in Swift

iOS Pod for a Soft UI (Neumorphic) Button for UIKit written in Swift

Custom loading button with progress swiftui

CustomLoadingButton Simple Custom Loading Progress Button for SwiftUI Version 1.0.0 This version requires Xcode 11+ SwiftUI iOS 13+ macOS 10.15+ Insta

An open-source library to use with SwiftUI, It allows you to create Floating menu action button.
An open-source library to use with SwiftUI, It allows you to create Floating menu action button.

Floating Menu Action Button Example Overview This is an open-source library to use with SwiftUI. It allows you to create Floating menu action button. Ins

iOS 7-style bouncy button.

SSBouncyButton SSBouncyButton is simple button UI component with iOS 7-style bouncy animation. Take A Look Try It! pod 'SSBouncyButton', '~ 1.0' Use

Flat button with 9 different states using POP
Flat button with 9 different states using POP

VBFPopFlatButton Flat button with 21 different states and 2 types animated using pop. These are some examples of both types in different states: And h

Flat design pressable button for iOS developers.
Flat design pressable button for iOS developers.

HTPressableButton HTPressableButton is designed for iOS developers to be able to spend time developing ideas, not building basic buttons. These stylis

Material Design Floating Action Button in liquid state
Material Design Floating Action Button in liquid state

LiquidFloatingActionButton [] (https://github.com/Carthage/Carthage) LiquidFloatingActionButton is floating action button component of material design

Simple and customizable button in Swift
Simple and customizable button in Swift

SwiftyButton Maintainer(s): @nickm01 @pmacro @aryamansharda Simple and customizable button in Swift. Installation Cocoapods pod 'SwiftyButton' Cartha

Animated Play and Pause Button written in Swift, using CALayer, CAKeyframeAnimation.
Animated Play and Pause Button written in Swift, using CALayer, CAKeyframeAnimation.

AnimatablePlayButton Animated Play and Pause Button written in Swift, using CALayer, CAKeyframeAnimation. features Only using CAShapeLayer, CAKeyframe

Comments
  • Minimum iOS platform version requirement

    Minimum iOS platform version requirement

    Why has the platform dependency changed to require iOS12? This makes it such that any app that requires supporting a past OS version can't use the Pod even though from a code perspective it still fully supports them. Upgrading to Swift 4.2 shouldn't require a minimum version dependency change from 11 to 12. Could this please be changed back? Jumping from iOS 8 to 12 is a huge change.

    opened by pushchris 3
  • Swift 3 --> Swift 4 name changes.

    Swift 3 --> Swift 4 name changes.

    Changed kCAFillModeBoth to the new Siwft 4 naming CAMediaTimingFillMode.both Changed kCAMediaTimingFunctionEaseOut to the new Siwft 4 naming CAMediaTimingFunctionName.easeOut

    opened by BaselNsralla 1
  • ui not change from downloaded   to  toDownload

    ui not change from downloaded to toDownload

    when progress retch 1.0 to download statue change automatically to downloaded which will Asyn the animation, the issues are that I used Firebase storage to download items and after muy quota end I found that before it throws an error the progress gets to 1.0 before the failure callback trigger which triggers downloaded Status automatically even when changing status manually to toDownload the UI not change. I know the issues are not totally from here but I suggest that retch 1.0 progress doesn't have to change the status automatically.

    opened by embassem 0
  • Failed to update auto layout status: The agent crashed

    Failed to update auto layout status: The agent crashed

    After I assigned NFDownloadButton to a UIView, I get this error:

    IB Designables: Failed to update auto layout status: The agent crashed
    

    And If i want to create it programmatically, get this error:

    'NFDownloadButton' initializer is inaccessible due to 'internal' protection level
    
    bug wontfix 
    opened by emptyway 9
Releases(0.0.6)
Inspired by Apple’s download progress buttons in the app store

GBKUIButtonProgressView Inspired by Apple’s download progress buttons in the app store Created by @pklada and @miketsprague Checkout the blog post. In

Guidebook 541 Sep 1, 2022
Cute Animated Button written in Swift.

DOFavoriteButton Cute Animated Button written in Swift. It could be just right for favorite buttons! Requirements iOS 7.0+ Swift 1.2 Installation Cart

Daiki Okumura 3.6k Dec 29, 2022
Customizable and easy to use expandable button in Swift.

ExpandableButton Requirements iOS 9.0+ Installation CocoaPods: Add the following line to your Podfile: pod 'ExpandableButton' #for swift less than 4.

Dmytro Mishchenko 98 Dec 5, 2022
Easily customizable floating button menu created with SwiftUI

FloatingButton Easily customizable floating button menu created with SwiftUI We are a development agency building phenomenal apps. Usage Create main b

Exyte 715 Dec 30, 2022
Floaty is simple floating action button for iOS.

Floaty is simple floating action button for iOS. (formerly KCFloatingActionButton) Why change the name? Follow the swift naming convention. KCF

Lee Sun-Hyoup 1.5k Jan 7, 2023
IGStoryButtonKit provides an easy-to-use button with rich animation and multiple way inspired by instagram story/stories.

Introduction Have you ever seen UI like instagram story, haven't you? Actually, features like instagram story have been implemented in many applicatio

mutation 34 Nov 8, 2022
LTHRadioButton - A radio button with a pretty animation

LTHRadioButton Slightly inspired by Google's material radio button. The clip below has 3 sections: full speed, 25% and 10%, but after converting it to

Roland Leth 368 Dec 16, 2022
Multiple state tap-to-toggle UIButton (like old camera flash button)

Multiple State Toggle UIButton A UIButton subclass that implements tap-to-toggle button text. (Like the camera flash and timer buttons) Usage Just cre

Yonat Sharon 83 Oct 11, 2022
Lickable-Button We made the buttons on the screen look so good you'll want to lick them

Lickable-Button We made the buttons on the screen look so good you'll want to lick them. - Steve Jobs A little SwiftUI button project at WWDC 2021 Lic

Nate Thompson 14 Dec 29, 2021
Craft that perfect SwiftUI button effect 👌🏼

buttoncraft (SwiftUI 3.0 App) Experimenting with SwiftUI 3.0 whilst creating a practical app to craft that perfect button style. ✈️ Testflight https:/

An Trinh 188 Dec 28, 2022