FloatyActivityIndicatorController 1.0.3

FloatyActivityIndicatorController 1.0.3

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新版本2017年9月
SwiftSwift 版本4.0
SPM支持 SPM

Dario Trisciuoglio 维护。



  • 作者:
  • Dario Trisciuoglio

FloatyActivityIndicatorController

ActivityIndicatorController 是一个 iOS 类,用于在后台线程运行时显示指示器。

使用方法

要运行示例项目,请克隆仓库,然后在 Example 目录下首先运行 pod install

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()
}

也支持 xib 和 storyboard

您甚至可以在动画开始后设置 lineWidthstrokeColor 属性,这在包含的示例项目中可以观察到。

需求

  • iOS 8.0+
  • Xcode 8.2
  • Swift 3.0+

安装

CocoaPods

作者

Dario Trisciuoglio

许可证

FloatyActivityIndicatorController 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。