Note: This tutorial has been updated (04/09/2017) to use Xcode 8.3.3, iOS 10, and Swift 3.
In this video, I show you how to implement and display an activity indicator
Facebook Page :- / iosinfoandknowledge
Collectionview inside ScrollView :- • Collectionview inside Scrollview
Dynamic height TableView in a Scroll View :- • Dynamic height TableView in a Scroll View
My Social Media link is below
-------------
instagram :- / gdivyesh40
facebook :- https://www.facebook.com/profile.php?...
code .......
// Created by Divyesh Gondaliya on 04/09/17.
// Copyright © 2017 Divyesh Gondaliya. All rights reserved.
//
import Foundation
import UIKit
open class indicatorView: UIActivityIndicatorView {
var overlayView = UIView()
var backView = UIView()
var activityIndicator = UIActivityIndicatorView()
class var shared: indicatorView {
struct Static {
static let instance: indicatorView = indicatorView()
}
return Static.instance
}
open func showOverlay(_ view: UIView) {
overlayView.frame = CGRect(x: 0, y: 0, width: 50 , height: 50)
backView.frame = CGRect(x: 0, y: 0, width: view.frame.width , height: view.frame.height)
backView.center = view.center
let white = UIColor ( red: 1/255, green: 0/255, blue:0/255, alpha: 0.0 )
backView.backgroundColor = white
view.addSubview(backView)
overlayView.center = view.center
let mygreenColor = UIColor ( red: 62.0/255, green: 181.0/255, blue:29.0/255, alpha: 1.0 )
overlayView.backgroundColor = mygreenColor
overlayView.clipsToBounds = true
overlayView.layer.cornerRadius = 10
activityIndicator.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
activityIndicator.center = overlayView.center
activityIndicator.activityIndicatorViewStyle = .white
activityIndicator.center = CGPoint(x: overlayView.bounds.width / 2, y: overlayView.bounds.height / 2)
overlayView.addSubview(activityIndicator)
view.addSubview(overlayView)
activityIndicator.startAnimating()
}
open func hideOverlayView() {
activityIndicator.stopAnimating()
activityIndicator.isHidden = true
overlayView.removeFromSuperview()
backView.removeFromSuperview()
}
}