Code Monkey home page Code Monkey logo

shimmerswift's Introduction

ShimmerSwift

A swift implementation of Facebooks shimmer effect.

demo

Requirements

  • Swift 4.2
  • iOS 10+

Installation

Cocoapods

Add pod 'ShimmerSwift' to your Podfile.

Carthage

Add github "BeauNouvelle/ShimmerSwift" to your Cartfile.

Manual

Download the .zip from this repo and drag the Shimmer folder into your project.

Useage

Shimmer is super easy to get started with.

Simply create a ShimmeringView or ShimmeringLayer and add your content.

// Setup ShimmeringView
let shimmerView = ShimmeringView(frame: self.view.bounds)
self.view.addSubview(shimmerView)

// Setup the view you want shimmered
let label = UILabel(frame: shimmerView.bounds)
label.text = "This is my shimmering text"

// Add the view you want shimmered to the `shimmerView`
shimmerView.contentView = label

// Start shimmering
shimmerView.isShimmering = true

// To stop shimmering.
shimmerView.isShimmering = false

Customization

All customizable properties are well documented in code, and are reproduced below.


contentView

The content view to be shimmered

contentView: UIView

isShimmering

Set to true to start shimmer animation, and false to stop. Detaults to false.

isShimmering: Bool

shimmerSpeed

The speed of the shimmer animation in points per second. The higher the number, the faster the animation.

Defaults to 230.

shimmerSpeed: CGFloat

shimmerHighlightLength

The highlight length of the shimmer. Range of [0,1], defaults to 1.0.

shimmerHighlightLength: CGFloat

shimmerDirection

The direction of the shimmer animation. Defaults to .right, which will run the animation from left to right.

shimmerDirection: Shimmer.Direction

shimmerPauseDuration

The time interval between shimmers in seconds. Defaults to 0.4.

shimmerPauseDuration: CFTimeInterval

shimmerAnimationOpacity

The opacity of the content during a shimmer. Defaults to 0.5.

shimmerAnimationOpacity: CGFloat

shimmerOpacity

The opacity of the content when not shimmering. Defaults to 1.0.

shimmerOpacity: CGFloat

shimmerBeginFadeDuration

The duration of the fade used when the shimmer begins. Defaults to 0.1.

shimmerBeginFadeDuration: CFTimeInterval

shimmerEndFadeDuration

The duration of the fade used when the shimmer ends. Defaults to 0.3.

shimmerEndFadeDuration: CFTimeInterval

shimmerswift's People

Contributors

beaunouvelle avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.