口袋优选

WebviewProgressLine.m 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // WebviewProgressLine.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/6/22.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "WebviewProgressLine.h"
  9. @implementation WebviewProgressLine
  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. self.width = 0.0;
  25. __weak UIView *weakSelf = self;
  26. [UIView animateWithDuration:0.4 animations:^{
  27. weakSelf.width = SCREEN_WIDTH * 0.6;
  28. } completion:^(BOOL finished) {
  29. [UIView animateWithDuration:0.4 animations:^{
  30. weakSelf.width = SCREEN_WIDTH * 0.8;
  31. }];
  32. }];
  33. }
  34. -(void)endLoadingAnimation{
  35. __weak UIView *weakSelf = self;
  36. [UIView animateWithDuration:0.2 animations:^{
  37. weakSelf.width = SCREEN_WIDTH;
  38. } completion:^(BOOL finished) {
  39. weakSelf.hidden = YES;
  40. }];
  41. }
  42. @end