Custom loading indicator with animation.
=======================
VzLoadingIndicator
is a custom loading indicator with animation.
Install Cocoapods if need be.
$ gem install cocoapods
Add VZLoadingIndicator
in your Podfile
.
use_frameworks!
pod 'VZLoadingIndicator'
Add source URLs
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/hassan8357/VZLoadingIndicator.git’
Then, run the following command.
$ pod install
import VZLoadingIndicatorView & UIWindow+Additions in AppDelegate
#import "VZLoadingIndicatorView.h"
#import "UIWindow+Additions.h"
define sharedAppDelegate
#define appDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])
create loadingView
@property (strong, nonatomic) VZLoadingIndicatorView *loadingView;
Add start method and end methods in app delegate to add/remove loadingView to current visable view
- (void)startActivityIndicator{
if (!appDelegate.loadingView)
{
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
appDelegate.loadingView = [[VZLoadingIndicatorView alloc] init];
[appDelegate.loadingView setImagesArray:@[@"L.png", @"L2.png",@"L3.png", @"L4.png",@"L5.png", @"L6.png", @"L7.png"]];
UIViewController *visibleViewController = [self.window visibleViewController];
UIViewController *viewController = visibleViewController;
if (visibleViewController.navigationController)
{
visibleViewController.navigationController.interactivePopGestureRecognizer.enabled = NO;
viewController = visibleViewController.navigationController;
}
CGRect frame = viewController.view.frame;
frame.size.width = viewController.view.frame.size.width ;
frame.size.height = viewController.view.frame.size.height;
frame.origin.x = 0;
frame.origin.y = 0;
appDelegate.loadingView.frame = frame;
[viewController.view addSubview: appDelegate.loadingView];
[appDelegate.loadingView startAnimation];
}
}
- (void)stopActivityIndicator{
UIViewController *visibleViewController = [self.window visibleViewController];
UIViewController *viewController = visibleViewController;
if (visibleViewController.navigationController) {
visibleViewController.navigationController.interactivePopGestureRecognizer.enabled = YES;
viewController = visibleViewController.navigationController;
}
if (appDelegate.loadingView) {
[appDelegate.loadingView stopAnimation];
[appDelegate.loadingView removeFromSuperview];
appDelegate.loadingView = nil;
}
}
you should set images array to loadingView to animate them.
[appDelegate.loadingView setImagesArray:@[@"L.png", @"L2.png",@"L3.png", @"L4.png",@"L5.png", @"L6.png", @"L7.png"]];
Hassan Refaat
The MIT License (MIT)
Copyright (c) 2017 Hassan Refaat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.