CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

FloatyActivityIndicatorController 1.0.3

FloatyActivityIndicatorController 1.0.3

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2017
SwiftSwift Version 4.0
SPMSupports SPM

Maintained by Dario Trisciuoglio.



  • By
  • Dario Trisciuoglio

FloatyActivityIndicatorController

ActivityIndicatorController is an iOS class that displays an indicator while work is being done in a background thread.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

ActivityIndicatorView

// Initialize the activity indicator view
let origin = CGPoint(x:40, y:40)
let size = CGSize(width:40, height:40)
let frame = CGRect(origin:origin, size:size)
let activityIndicatorView = ActivityIndicatorView(frame: frame)

// Set the line width of the activity indicator view
activityIndicatorView.lineWidth = 4

// Set the color of the activity indicator view
activityIndicatorView.tintColor = UIColor.red

// Add it as a subview
self.view.addSubview(activityIndicatorView)

// Start animation
activityIndicatorView.startAnimating()

// Stop animation
//activityIndicatorView.stopAnimating()

ActivityIndicatorController

// Create the URLSessionConfiguration and then create a session with that configuration.
let configuration = URLSessionConfiguration.default
let session = URLSession(configuration: configuration)

// Initialize the shared instance activity indicator controller.
let activityIndicator = ActivityIndicatorController.shared
// Set the color of the activity indicator view
activityIndicator.view.tintColor = UIColor.red

// Set the line width of the activity indicator view
activityIndicator.activityIndicatorView?.lineWidth = 4;

// Create the URLRequest using either an URL
if let url = URL.init(string: "https://httpbin.org/get") {

    let request = URLRequest(url: url)

    // Show the activity indicator
    activityIndicator.show()

    // Or set the color after call the show()
    //activityIndicator.activityIndicatorView?.tintColor = UIColor.red

    // Call the web service
    let dataTask = session.dataTask(with: request, completionHandler: {_,_,_ in

        // Hide the activity indicator
        activityIndicator.hide()
    })
    dataTask.resume()
}

Also support xib and storyboard

The lineWidth and strokeColor properties can even be set after animating has been started, which you can observe in the included example project.

Requirements

  • iOS 8.0+
  • Xcode 8.2
  • Swift 3.0+

Installation

CocoaPods

Author

Dario Trisciuoglio

License

FloatyActivityIndicatorController is available under the MIT license. See the LICENSE file for more info.