...
|
...
|
@@ -8,6 +8,11 @@ |
|
|
|
|
|
#import "YHWebViewProgressView.h"
|
|
|
|
|
|
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
|
|
|
//大于等于8.0的ios版本
|
|
|
#define iOS8_OR_LATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")
|
|
|
|
|
|
|
|
|
#define kAnimationDurationMultiplier (1.8)
|
|
|
|
|
|
@interface YHWebViewProgressView ()
|
...
|
...
|
@@ -91,13 +96,17 @@ |
|
|
- (void)setProgress:(float)progress animated:(BOOL)animated
|
|
|
{
|
|
|
BOOL isGrowing = progress > 0.f;
|
|
|
UIImageView * maskImageView =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.progressBarView.frame), CGRectGetHeight(self.progressBarView.frame))];
|
|
|
UIImageView * maskImageView = [[UIImageView alloc]init];
|
|
|
if (iOS8_OR_LATER) {
|
|
|
[maskImageView setFrame:CGRectMake(0, 0, CGRectGetWidth(self.progressBarView.frame), CGRectGetHeight(self.progressBarView.frame))];
|
|
|
self.progressBarView.maskView = maskImageView;
|
|
|
}else{
|
|
|
[maskImageView setFrame:CGRectMake(0, 0, CGRectGetWidth(self.progressBarView.frame), CGRectGetHeight(self.progressBarView.frame))];
|
|
|
CALayer *layer = [CALayer layer];
|
|
|
[layer setFrame:CGRectMake(0, 0, CGRectGetWidth(self.progressBarView.frame), CGRectGetHeight(self.progressBarView.frame))];
|
|
|
[layer setContents:(id)[UIImage imageNamed:@"Mask"].CGImage];
|
|
|
// self.progressBarView.maskView = maskImageView;
|
|
|
[self.progressBarView addSubview:maskImageView];
|
|
|
|
|
|
}
|
|
|
CGFloat originX = -CGRectGetWidth(self.bounds)/2;
|
|
|
CGPoint positionBegin = CGPointMake(originX+_progress * self.bounds.size.width, CGRectGetHeight(self.progressBarView.frame)/2);
|
|
|
CGPoint positionEnd = CGPointMake(originX+progress * self.bounds.size.width, CGRectGetHeight(self.progressBarView.frame)/2);
|
...
|
...
|
|