| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- //
- // RAActivityIndicator+Show.m
- // Test
- //
- // Created by Jack on 2019/2/1.
- // Copyright © 2019 Jack Template. All rights reserved.
- //
- #import "RAActivityIndicator+Show.h"
- @implementation RAActivityIndicator (Show)
- + (instancetype)activityIndicatorShowOnView:(UIView *)view withType:(RAActivityType)type {
-
- RAActivityIndicator *indicator = [RAActivityIndicator activityIndicatorWithType:type];
-
- [view addSubview:indicator];
-
- indicator.translatesAutoresizingMaskIntoConstraints = NO;
-
- CGFloat indicator_width = CGRectGetWidth(indicator.frame);
- CGFloat indicator_height = CGRectGetHeight(indicator.frame);
-
- [indicator.centerXAnchor constraintEqualToAnchor:view.centerXAnchor].active = YES;
- [indicator.centerYAnchor constraintEqualToAnchor:view.centerYAnchor].active = YES;
- [indicator.widthAnchor constraintEqualToConstant:indicator_width].active = YES;
- [indicator.heightAnchor constraintEqualToConstant:indicator_height].active = YES;
-
- return indicator;
- }
- - (void)dismiss {
- [self dismiss:nil];
- }
- - (void)dismiss:(void(^)(void))completion {
-
- [UIView animateWithDuration:0.5 animations:^{
-
- self.alpha = 0.4f;
- } completion:^(BOOL finished) {
-
- if (completion) {
- completion();
- }
- [self removeFromSuperview];
- }];
- }
- @end
|