Description
AHDownloadButton is a customizable download button similar to the download button in the latest version of Apple's App Store app (since iOS 11). It features download progress animation as well as animated transitions between download states: start download, pending, downloading and downloaded.
AHDownloadButton alternatives and similar libraries
Based on the "Animation" category.
Alternatively, view AHDownloadButton alternatives based on common mentions on social networks and blogs.
-
Pop
An extensible iOS and OS X animation library, useful for physics-based interactions. -
Shimmer
An easy way to add a simple, shimmering effect to any view in an iOS app. -
IBAnimatable
Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable. -
Keyframes
A library for converting Adobe AE shape based animations to a data format and play it back on Android and iOS devices. -
JHChainableAnimations
Easy to read and write chainable animations in Objective-C and Swift -
EasyAnimation
A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together! -
Chat App
Real time chat app written in Swift 5 using Firebase -
RZTransitions
A library of custom iOS View Controller Animations and Interactions. -
PulsingHalo
iOS Component for creating a pulsing animation. -
DKChainableAnimationKit
⭐ Chainable animations in Swift -
CKWaveCollectionViewTransition
Cool wave like transition between two or more UICollectionView -
Interpolate
Swift interpolation for gesture-driven animations -
LSAnimator
⛓ Easy to Read and Write Multi-chain Animations Lib in Objective-C and Swift. -
Popsicle
Delightful, extensible Swift value interpolation framework -
Awesome-iOS-Animation
Curated list of iOS Animation libraries -
AnimationEngine
Easily build advanced custom animations on iOS. -
ActivityIndicatorView
A number of preset loading indicators created with SwiftUI -
DCAnimationKit
A collection of animations for iOS. Simple, just add water animations. -
ZoomTransitioning
ZoomTransitioning provides a custom transition with image zooming animation and swiping the screen edge. -
FlightAnimator
Advanced Natural Motion Animations, Simple Blocks Based Syntax -
JDAnimationKit
Animate easy and with less code with Swift -
AHKBendableView
UIView subclass that bends its edges when its position changes. -
Animo
Bring life to CALayers with SpriteKit-like animation builders -
MotionMachine
A powerful, elegant, and modular animation library for Swift. -
RippleEffectView
RippleEffectView - A Neat Rippling View Effect -
SamuraiTransition
SamuraiTransition is an open source Swift based library providing a collection of ViewController transitions featuring a number of neat “cutting” animations. -
JRMFloatingAnimation
An Objective-C animation library used to create floating image views. -
CCMRadarView
CCMRadarView uses the IBDesignable tools to make an easy customizable radar view with animation -
ConcentricProgressRingView
Fully customizable circular progress bar written in Swift. -
Walker
Each step you take reveals a new horizon. You have taken the first step today. -
SYBlinkAnimationKit
A blink effect animation framework for iOS, written in Swift. -
ADPuzzleAnimation
Inspired by Fabric - Answers animation. Allows to "build" given view with pieces. Allows to "destroy" given view into pieces -
Stagehand
Modern, type-safe API for building animations on iOS -
SMSwipeableTabView
Swipeable Views with Tabs (Like Android SwipeView With Tabs Layout)
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of AHDownloadButton or a related project?
README
AHDownloadButton is a customizable download button similar to the download button in the latest version of Apple's App Store app (since iOS 11). It features download progress animation as well as animated transitions between download states: start download, pending, downloading and downloaded. You can find more details about the implementation on my blog.
Requirements
- iOS 8.0+
- Xcode 10.2+
- Swift 5.0+
Usage
Code
To use AHDownloadButton
in code, you simply create a new instance and add it as a subview to your desired view:
let downloadButton = AHDownloadButton()
downloadButton.frame = CGRect(origin: origin, size: size)
view.addSubview(downloadButton)
The button can have 4 different states:
startDownload
- initial state before downloadingpending
- state for preparing for downloaddownloading
- state when the user is downloadingdownloaded
- state when the user finished downloading
The state of the button can be changed through its state
property.
Delegate
You can use the AHDownloadButtonDelegate
to monitor taps on the button and update button's state if needed. To update the current download progress, use the progress
property. Here is an example how it could be implemented:
extension DownloadViewController: AHDownloadButtonDelegate {
func downloadButton(_ downloadButton: AHDownloadButton, tappedWithState state: AHDownloadButton.State)
switch state {
case .startDownload:
// set the download progress to 0
downloadButton.progress = 0
// change state to pending and wait for download to start
downloadButton.state = .pending
// initiate download and update state to .downloading
startDownloadingFile()
case .pending:
// button tapped while in pending state
break
case .downloading:
// button tapped while in downloading state - stop downloading
downloadButton.progress = 0
downloadButton.state = .startDownload
case .downloaded:
// file is downloaded and can be opened
openDownloadedFile()
}
}
}
You can also use closures instead of the AHDownloadButtonDelegate
by setting the didTapDownloadButtonAction
and downloadButtonStateChangedAction
properties.
Customisation
AHDownloadButton
can be customized. These are the properties that can be used for customizing the button:
Use the custom initializer
init(alignment: HorizontalAlignment)
to set the horizontal alignment property.HorizontalAlignment
determines the position of the pending and downloading circles. The position can either becenter
,left
orright
. The default value iscenter
.Customization properties when button is in
startDownload
state:
startDownloadButtonTitle
- button's titlestartDownloadButtonTitleFont
- button's title fontstartDownloadButtonTitleSidePadding
- padding for left and right side of button's titlestartDownloadButtonHighlightedBackgroundColor
- background color for the button when it's in highlighted state (when the user presses the button)startDownloadButtonNonhighlightedBackgroundColor
- background color for the button when it's in nonhighlighted state (when the button is not pressed)startDownloadButtonHighlightedTitleColor
- title color for the button when it's in highlighted state (when the user presses the button)startDownloadButtonNonhighlightedTitleColor
- title color for the button when it's in nonhighlighted state (when the button is not pressed)
- Customization properties when button is in
pending
state:
pendingCircleColor
- color of the pending circlependingCircleLineWidth
- width of the pending circle
- Customization properties when button is in
downloading
state:
downloadingButtonHighlightedTrackCircleColor
- color for the track circle when it's in highlighted state (when the user presses the button)downloadingButtonNonhighlightedTrackCircleColor
- color for the track circle when it's in nonhighlighted state (when the button is not pressed)downloadingButtonHighlightedProgressCircleColor
- color for the progress circle when it's in highlighted state (when the user presses the button)downloadingButtonNonhighlightedProgressCircleColor
- color for the progress circle when it's in nonhighlighted state (when the button is not pressed)downloadingButtonHighlightedStopViewColor
- color for the stop view in the middle of the progress circle when it's in highlighted state (when the user presses the button)downloadingButtonNonhighlightedStopViewColor
- color for the stop view in the middle of the progress circle when it's in nonhighlighted state (when the button is not pressed)downloadingButtonCircleLineWidth
- width of the downloading circle
- Customization properties when button is in
downloaded
state:
downloadedButtonTitle
- button's titledownloadedButtonTitleFont
- button's title fontdownloadedButtonTitleSidePadding
- padding for left and right side of button's titledownloadedButtonHighlightedBackgroundColor
- background color for the button when it's in highlighted state (when the user presses the button)downloadedButtonNonhighlightedBackgroundColor
- background color for the button when it's in nonhighlighted state (when the button is not pressed)downloadedButtonHighlightedTitleColor
- title color for the button when it's in highlighted state (when the user presses the button)downloadedButtonNonhighlightedTitleColor
- title color for the button when it's in nonhighlighted state (when the button is not pressed)
transitionAnimationDuration
- animation duration between the different states of the button
Special note
AHDownloadButton
in startDownload
and downloaded
states calculates its width based on button title. Use the startDownloadButtonTitleSidePadding
and downloadedButtonTitleSidePadding
properties to customise the width when the button is in the aforementioned states.
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate AHDownloadButton into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
target '<Your Target Name>' do
pod 'AHDownloadButton'
end
Then, run the following command:
$ pod install
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate AHDownloadButton into your Xcode project using Carthage, specify it in your Cartfile
:
github "amerhukic/AHDownloadButton" ~> 1.3.0
Swift Package Manager
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift
compiler.
Once you have your Swift package set up, adding AHDownloadButton as a dependency is as easy as adding it to the dependencies
value of your Package.swift
.
dependencies: [
.package(url: "https://github.com/amerhukic/AHDownloadButton", .upToNextMajor(from: "1.3.0"))
]
Author
License
AHDownloadButton is licensed under the MIT license. Check the [LICENSE](LICENSE) file for details.
*Note that all licence references and agreements mentioned in the AHDownloadButton README section above
are relevant to that project's source code only.