JXWebviewProgress.m 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // JXWebviewProgress.m
  3. // shiku_im
  4. //
  5. // Created by 1 on 2019/4/8.
  6. // Copyright © 2019年 Reese. All rights reserved.
  7. //
  8. #import "JXWebviewProgress.h"
  9. @implementation JXWebviewProgress
  10. -(instancetype)initWithFrame:(CGRect)frame{
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. self.hidden = YES;
  14. self.backgroundColor = [UIColor whiteColor];
  15. }
  16. return self;
  17. }
  18. -(void)setLineColor:(UIColor *)lineColor{
  19. _lineColor = lineColor;
  20. self.backgroundColor = lineColor;
  21. }
  22. -(void)startLoadingAnimation{
  23. self.hidden = NO;
  24. __weak UIView *weakSelf = self;
  25. [UIView animateWithDuration:0.4 animations:^{
  26. [self getWidth:JX_SCREEN_WIDTH * 0.6 view:weakSelf];
  27. } completion:^(BOOL finished) {
  28. [UIView animateWithDuration:1. animations:^{
  29. [self getWidth:JX_SCREEN_WIDTH * 0.8 view:weakSelf];
  30. }];
  31. }];
  32. }
  33. - (void)getWidth:(CGFloat)width view:(UIView *)view {
  34. CGRect frame = view.frame;
  35. frame.size.width = width;
  36. view.frame = frame;
  37. }
  38. -(void)endLoadingAnimation{
  39. __weak UIView *weakSelf = self;
  40. [UIView animateWithDuration:0.2 animations:^{
  41. [self getWidth:JX_SCREEN_WIDTH view:weakSelf];
  42. } completion:^(BOOL finished) {
  43. weakSelf.hidden = YES;
  44. }];
  45. }
  46. @end