diff --git a/swift/ViewControllerUtils.swift b/swift/ViewControllerUtils.swift index 16e9529..25b7998 100644 --- a/swift/ViewControllerUtils.swift +++ b/swift/ViewControllerUtils.swift @@ -6,51 +6,49 @@ class ViewControllerUtils { var container: UIView = UIView() var loadingView: UIView = UIView() var activityIndicator: UIActivityIndicatorView = UIActivityIndicatorView() - - /* - Show customized activity indicator, - actually add activity indicator to passing view - @param uiView - add activity indicator to this view - */ + /* + Show customized activity indicator, + actually add activity indicator to passing view + + @param uiView - add activity indicator to this view + */ func showActivityIndicator(uiView: UIView) { container.frame = uiView.frame container.center = uiView.center - container.backgroundColor = UIColorFromHex(0xffffff, alpha: 0.3) - - loadingView.frame = CGRectMake(0, 0, 80, 80) + container.backgroundColor = UIColorFromHex(rgbValue: 0xffffff, alpha: 0.3) + loadingView.frame = CGRect(x: 0, y: 0, width: 80, height: 80) loadingView.center = uiView.center - loadingView.backgroundColor = UIColorFromHex(0x444444, alpha: 0.7) + loadingView.backgroundColor = UIColorFromHex(rgbValue: 0x444444, alpha: 0.7) loadingView.clipsToBounds = true loadingView.layer.cornerRadius = 10 - - activityIndicator.frame = CGRectMake(0.0, 0.0, 40.0, 40.0); - activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge - activityIndicator.center = CGPointMake(loadingView.frame.size.width / 2, loadingView.frame.size.height / 2); - + + activityIndicator.frame = CGRect(x: 0.0, y: 0.0, width: 40.0, height: 40.0) + activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.whiteLarge + activityIndicator.center = CGPoint(x: loadingView.frame.size.width / 2, y: loadingView.frame.size.height / 2) loadingView.addSubview(activityIndicator) container.addSubview(loadingView) uiView.addSubview(container) activityIndicator.startAnimating() } - - /* - Hide activity indicator - Actually remove activity indicator from its super view - @param uiView - remove activity indicator from this view - */ + /* + Hide activity indicator + Actually remove activity indicator from its super view + + @param uiView - remove activity indicator from this view + */ func hideActivityIndicator(uiView: UIView) { activityIndicator.stopAnimating() container.removeFromSuperview() } - + /* - Define UIColor from hex value - - @param rgbValue - hex color value - @param alpha - transparency level - */ + Define UIColor from hex value + + @param rgbValue - hex color value + @param alpha - transparency level + */ func UIColorFromHex(rgbValue:UInt32, alpha:Double=1.0)->UIColor { let red = CGFloat((rgbValue & 0xFF0000) >> 16)/256.0 let green = CGFloat((rgbValue & 0xFF00) >> 8)/256.0 @@ -61,8 +59,8 @@ class ViewControllerUtils { } //// In order to show the activity indicator, call the function from your view controller -//// ViewControllerUtils().showActivityIndicator(self.view) +//// ViewControllerUtils().showActivityIndicator(uiView: self.view) //// In order to hide the activity indicator, call the function from your view controller -//// ViewControllerUtils().hideActivityIndicator(self.view) +//// ViewControllerUtils().hideActivityIndicator(uiView: self.view) diff --git a/swift/screenshot.png b/swift/screenshot.png new file mode 100644 index 0000000..3a4d65d Binary files /dev/null and b/swift/screenshot.png differ