Windless makes it easy to implement invisible layout loading view.

Contents

Requirements

  • IOS 8.0 +
  • Xcode 9.0 +
  • Swift 4.0 +

Installation

CocoaPods

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

$ gem install cocoapodsCopy the code

CocoaPods 1.1+ is required to build Windless 4.0+.

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

The source 'https://github.com/CocoaPods/Specs.git' platform: ios, '8.0' use_frameworks! Target '<Your target Name>' do pod 'Windless', '~> 0.1.4' endCopy the code

Then, run the following command:

$ pod installCopy the code

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthageCopy the code

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

Making "Interactive - Studio/Windless" ~ > 0.1.4Copy the code

Run carthage update to build the framework and drag the built Windless.framework into your Xcode project.

Manually

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


Usage

Code

import Windless

class ViewController: UIViewController {

    lazy var contentsView = UIView()
    
    var subView1 = UIView()
    var subView2 = UIView()

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.addSubview(contentsView)
        contentsView.addSubview(subView1)
        contentsView.addSubview(subView2)
        
        // start
        contentsView.windless
                .setupWindlessableViews([subView1, subView2])
                .start()
                
        // stop
        contentsView.windless.end()
    }

}Copy the code

Storyboard, Xib

If you use Storyboard or xib, you only need to set the isWindlessable flag to true for the views you want to show as fake in the view inspector of the view, and you do not have to pass the view through the setupWindlessableViews method.

import Windless

class ViewController: UIViewController {

    @IBOutlet weak var contentsView: UIView!

    override func viewDidLoad() {
        super.viewDidLoad()

        contentsView.windless.start()
    }
}Copy the code

Custom Options

There are several customizable options in Windless.

public class WindlessConfiguration {
    
    /// The direction of windless animation. Defaults to rightDiagonal.
    public var direction: WindlessDirection = .rightDiagonal
    
    /// The speed of windless animation. Defaults to 1.
    public var speed: Float = 1
    
    /// The duration of the fade used when windless begins. Defaults to 0.
    public var beginTime: CFTimeInterval = 0
    
    /// The time interval windless in seconds. Defaults to 4.
    public var duration: CFTimeInterval = 4
    
    /// The time interval between windless in seconds. Defaults to 2.
    public var pauseDuration: CFTimeInterval = 2
    
    /// gradient animation timingFunction default easeOut
    public var timingFuction: CAMediaTimingFunction = .easeOut
    
    /// gradient layer center color default .lightGray
    public var animationLayerColor: UIColor = .lightGray
    
    /// Mask layer background color default .groupTableViewBackground
    public var animationBackgroundColor: UIColor = .groupTableViewBackground
    
    /// The opacity of the content while it is windless. Defaults to 0.8.
    public var animationLayerOpacity: CGFloat = 0.8
}Copy the code

To set the options, use the apply method as shown below.

import Windless class ViewController: UIViewController { @IBOutlet weak var contentsView: UIView! override func viewDidLoad() { super.viewDidLoad() contentsView.windless .apply { $0.beginTime = 1 $0.pauseDuration = 2 $0. Duration = 3 $0. AnimationLayerOpacity = 0.5}.start()}}Copy the code

If you want to know more detailed usage, please refer to Example.

Credits

  • GwangBeom Park (@gwangbeom)

License

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