• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Non-blocking animated gradient placeholder view for your async tasks.

LoadingPlaceholderView

Animated gradient placeholder with zero effort

Platform Swift 4 Cocoapods Compatible

Mixed UI Components Table View Collection View

Features

  • Plug and play
  • Supports all UIKit components and it's open to user-defined ones.
  • Supports landscape mode and runtime screen resize
  • Highly customizable
  • Swift 4 and iOS 9.0+

How it works

LoadingPlaceholderView extracts all the subviews that conforms the protocol Coverable from viewToCover and then creates an animated gradient layer combining all the coverablePath provided by each of those subviews.

Setup

CocoaPods

Add to your Podfile:

pod 'LoadingPlaceholderView'

Carthage

Add to your Cartfile:

github "MarioIannotta/LoadingPlaceholderView" "master"

Manually

Copy the content of the LoadingPlaceholderView folder into your project

How to use

  1. Create an instance of LoadingPlaceholderView

    let loadingPlaceholderView = LoadingPlaceholderView()

    Usually this would be a property of your view controller.

  2. Show the view with

    loadingPlaceholderView.cover(_ viewToCover: UIView, animated: Bool)

  3. Hide the view with

    loadingPlaceholderView.uncover(animated: Bool)

UITableView/UICollectionView

By design LoadingPlaceholderView doesn't interfere with DataSource and/orDelegate by injecting mocked data but it leaves the resposability to decide what to show and how to the user; in that way unwanted side effects are limited.

  1. Preload the tableView/collectionView with "mocked" cells. UITableViewCell and UICollectionViewCell already conforms Coverable

  2. Show the view with

    loadingPlaceholderView.cover(_ viewToCover: UIView, animated: Bool)

  3. Hide the view and refresh the tableView/collectionView

    loadingPlaceholderView.uncover(animated: Bool) tableView/collectionView.reloadData()

Note:

It is possible to set coverableCellsIdentifiers (just for UITableView) - in this way the current tableView state will be ignored and the coverablePath (and therefore the gradient) is generated using the provided cells identifies. In this way it is possible to skip the first step of the previous list because populating the tableView with mocked cells is no more required.

Customization

You can customize the component behavior by setting the followings properties:

fadeAnimationDuration: TimeInterval

The duration of the animation performed by the methods
cover(_ viewToCover: UIView, animated: Bool = true)
uncover(animated: Bool = true)
when animated is true

gradientColor: UIColor

The main color of the gradient. Once it has been set gradientConfiguration.backgroundColor, gradientConfiguration.primaryColor and gradientConfiguration.secondaryColor will be calculated based on this color.

gradientiConfiguration.width: Double

The width of the primary color in the gradient expressed as the percentage of the gradient size.

gradientiConfiguration.animationDuration: TimeInterval

The duration of the animation of the gradient.

gradientiConfiguration.backgroundColor: UIColor

The backgroundColor of the gradient.

gradientiConfiguration.primaryColor: UIColor

The primaryColor of the gradient.

gradientiConfiguration.secondaryColor: UIColor

The secondaryColor of the gradient.

Demo

In this repository you can also find a demo.

Info

If you like this git you can follow me here or on twitter :) @MarioIannotta

Cheers from Italy!

More Repositories

1

PullUpController

Pull up controller with multiple sticky points like in iOS Maps
Swift
1,243
star
2

MIBlurPopup

MIBlurPopup lets you create popups with a blurred background
Swift
605
star
3

SplitViewDragAndDrop

Drag and drop between your apps in split view mode on iOS 9
Swift
330
star
4

ShyView

A UI component that avoids screenshots and recordings
Swift
194
star
5

SwizzleSwift

Swizzle selectors with just one clean and elegant API
Swift
155
star
6

LocalizedSwift

Localize UI Components in a simple and declarative way
Swift
137
star
7

SwiftyContextMenu

UIContextMenu backporting with Swifter API
Swift
123
star
8

MIPivotPageController

MIPivotPageController allows switching view controllers with an horizontal swipe
Swift
89
star
9

MIAlertController

A simple fully customizable alert controller
Swift
54
star
10

BlurView

Custom blur radius for your UIKit views
Swift
39
star
11

Sivire

Record videos of your simulators from the mac menu bar
JavaScript
10
star
12

QuickLookFramework

A quick look plugin to inspect Frameworks
Swift
9
star
13

SwiftAcknowledgements

Extract your SPM dependencies licenses and add them to the Settings.bundle of your app
Swift
8
star
14

Nomosi

Declarative plug and play network services for your iOS and MacOS apps
Swift
7
star
15

SivireSDK

Add gesture to your video recorded with Sivire
Swift
4
star
16

GitProjects

A Swift script to extract stats from multiple git repositories
Swift
4
star
17

MIPlotter

Draw your histograms quickly and easily.
Objective-C
3
star
18

MIJsonParser

Just like json_encode, simple convert your arrays in valid json string.
PHP
1
star
19

Postfix-expression-evaluator

A script to evaluate mathematical expression in postfix notation
Python
1
star
20

MarioIannotta

1
star