GVLoadingView is compatible with ARC
GVLoadingView does not use threading. You may need to manage threading yourself in order to avoid UI blocking.
To install GVLoadingView, simply drag the GVLoadingView.h
and GVLoadingView.m
to your project. When asked, check the following fileds:
- Copy items into destination group's folder (if needed)
- Create groups for any added folders
- Add to targets (check all the desired targets)
Configuration of GVLoadingView is very simple. Go te .h file where you want GVLoadingView to appear and import it:
#import "GVLoadingView.h"
In your @interface
, instantiate an object of GVLoadingView class:
@interface MyViewController : UIViewController { GVLoadingView *loadingView; }
Initialize the object:
loadingView = [[GVLoadingView alloc] init];
To modify the behavior and the appearance of GVLoadingView, you can use the following properties:
Setting the loadingView background color:
loadingView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
If you want the loadingView to have transparency, set it in it's background color, so it will be kept even if you want to use the showing animation GVLoadingViewShowAnimationFade
@property (nonatomic, strong) UILabel *messageLabel;
This is the UILabel
that will show any message you wish. To set it's properties:
loadingView.messageLabel.text = @"Loading...";
loadingView.messageLabel.textColor = [UIColor whiteColor];
loadingView.messageLabel.font = [UIFont boldSystemFontOfSize:14];
loadingView.messageLabel.shadowOffset = CGSizeMake(0, -1);
loadingView.messageLabel.shadowColor = [UIColor blackColor];
If no text is set, no message will show.
@property (nonatomic, strong) UIActivityIndicatorView *spinner;
This is the UIActivityIndicatorView
that will appear to the left of the messageLabel
. It can be customized as well:
loadingView.spinner.activityIndicatorViewStyle = UIActivityInidcatorViewStyleWhite;
loadingView.spinner.color = [UIColor darkGrayColor];
@property (nonatomic) CGFloat *animationTime;
A float
value that defines the time in seconds that will take for the animations to complete.
@property (nonatomic, strong) UIImage *reloadImage;
This is the UIImage
that will appear in place of the UIActivityIndicatorView
when GVLoadingView enters reload mode. This image must be 20x23 pixels size on non-retine devices and 40x46 on retina devices.
@property (nonatomic) SEL *reloadMethod;
When GVLoadingView is in reload mode, it's whole area will be clickable. A tap on it's surface will trigger a method in the container view controller. To define this method, set the reloadMethod property:
loadingView.reloadMethod = @selector(anyMethodYouWant);
When the user tap GVLoadingView in reload mode, it will call the anyMethodYouWant
method.
@property (nonatomic, unsafe_unretained) UIViewController *delegate;
This is the GVLoadingView's delegate. It must be set to the class that owns the method that must be called when the user taps GVLoadingView in reload mode.
loadingView.delegate = (id)self;
- (void) showWithAnimation:(GVLoadingViewShowAnimation)animation;
This method will automatically add the loadingView
to the superview
and perform the chosen animation. The available animations for showing the loadingView
are:
GVLoadingViewShowAnimationAppear
The loadingView will come from the bottom of the screen, sliding in to the frame set.
GVLoadingViewShowAnimationFade
The loadingView will fade from completely transparent to completely opaque. If you want the loadingView background to remain a little transparent, you must set it's backgroundColor as: loadingView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
GVLoadingViewShowAnimationShutter
The loadingView will fade in from completely transparent with height 0px and resize it's height until it reaches the height set in the frame.
GVLoadingViewShowAnimationDrop
The loadingView will fade in from completely transparent and above the set vertical origin. It will slide down until it reaches the vertical origin set in the frame and will bounce twice.
GVLoadingViewShowAnimationNone
The loadingView will show up in the view with no animation
- (void) dismissWithAnimation:(GVLoadingViewDismissAnimation)animation;
This method will remove the loadingView from the view performing the chosen animation. The available animations for dismissing the loadingView
are:
GVLoadingViewDismissAnimationDisappear
The loadingView will slide to the bottom of the view until it's completely out of the view's frame, then it will be removed from the view.
GVLoadingViewDismissAnimationFade
The loadingView will fade out to completely transparent, then it will be removed from the view.
GVLoadingViewDismissAnimationShutter
The loadingView will reduce it's height until 0px while fading out to completely transparent and then it will be removed from the view.
GVLoadingViewDismissAnimationNone
The loadingView will be removed immediately from the view, with no animaitons.
- (void) enterReloadModeWithMessage:(NSString *) reloadMessage;
When this method is called, the UIActivityIndicatorView
will stop animating and disappear. In it's place will appear some reload image set by the property reloadImage
. The whole area of the view will be clickable. When loadingView is clicked, it will call the method set by the property reloadMethod
. The string passed as argument will replace the current message in the loadingView. For example:
[loadingView enterReloadMethodWithMessage:@"Load failed. Tap to reload."];
- (void) exitReloadModeWithMessage:(NSString *) reloadMessage;
When this method is called, the reloadImage
will disappear and in it's place the UIActivityIndicatorView
will reappear, animating. The string passed as argument will replace the current message in the loadingView. For example:
[loadingView exitReloadMethodWithMessage:@"Reloading..."];