...
|
...
|
@@ -13,6 +13,8 @@ |
|
|
<YHExplorerDelegate>
|
|
|
@property (weak, nonatomic) IBOutlet YHExplorerView *webView;
|
|
|
@property (strong, nonatomic) UITextView *tv;
|
|
|
@property (strong, nonatomic) UIVisualEffectView *blurView;
|
|
|
@property (strong, nonatomic) UIImageView *displayPictureView;
|
|
|
@end
|
|
|
|
|
|
@implementation WebViewController
|
...
|
...
|
@@ -32,6 +34,27 @@ |
|
|
return YES;
|
|
|
}
|
|
|
|
|
|
- (UIVisualEffectView *)blurView {
|
|
|
if (!_blurView) {
|
|
|
UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
|
|
|
_blurView = [[UIVisualEffectView alloc] initWithEffect:effect];
|
|
|
_blurView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 200.f);
|
|
|
[_blurView addSubview:self.displayPictureView];
|
|
|
_blurView.userInteractionEnabled = YES;
|
|
|
self.displayPictureView.frame = _blurView.bounds;
|
|
|
}
|
|
|
return _blurView;
|
|
|
}
|
|
|
|
|
|
- (UIImageView *)displayPictureView {
|
|
|
if (!_displayPictureView) {
|
|
|
_displayPictureView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
|
|
|
_displayPictureView.contentMode = UIViewContentModeScaleAspectFit;
|
|
|
_displayPictureView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
|
|
|
}
|
|
|
return _displayPictureView;
|
|
|
}
|
|
|
|
|
|
- (void)dealloc
|
|
|
{
|
|
|
|
...
|
...
|
@@ -52,6 +75,7 @@ |
|
|
[super viewDidLoad];
|
|
|
self.webView.delegate = self;
|
|
|
self.webView.enableProgressBar = YES;
|
|
|
self.webView.enablePictureTapGesture = YES;
|
|
|
|
|
|
[self.webView loadWebUrl:self.url];
|
|
|
// [self.webView loadWebUrl:[[NSBundle mainBundle] pathForResource:@"untitled" ofType:@"html"]];
|
...
|
...
|
@@ -68,6 +92,21 @@ |
|
|
// [self.webView loadHTMLString:html];
|
|
|
}
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
|
if (self.blurView.superview) {
|
|
|
[NSObject cancelPreviousPerformRequestsWithTarget:self];
|
|
|
[self performSelector:@selector(hideBlurView) withObject:nil afterDelay:2];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
[super viewWillDisappear:animated];
|
|
|
|
|
|
[NSObject cancelPreviousPerformRequestsWithTarget:self];
|
|
|
}
|
|
|
|
|
|
#pragma mark - YHExplorerDelegate
|
|
|
- (void)pageTitleUpdated:(NSString *)title
|
|
|
{
|
...
|
...
|
@@ -117,4 +156,61 @@ |
|
|
self.tv.text = [[NSString alloc] initWithFormat:@"url: %@\nopentype: %@\nopenParams:\n%@", freshUrl, openType, openParameters];
|
|
|
}
|
|
|
|
|
|
// H5上点击了图片的事件
|
|
|
- (void)explorer:(YHExplorerViewController *)explorer didClickPicture:(NSDictionary *)pictureInfo {
|
|
|
NSLog(@"explorer didClickPicture: \n%@", pictureInfo);
|
|
|
|
|
|
NSString *imageUrl = pictureInfo[@"url"];
|
|
|
|
|
|
if (imageUrl.length == 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
CGFloat width = CGRectGetWidth(self.view.frame);
|
|
|
CGFloat height = CGRectGetHeight(self.view.frame)-CGRectGetMaxY(self.navigationController.navigationBar.frame);
|
|
|
|
|
|
self.blurView.frame = CGRectMake((CGRectGetWidth(self.view.frame)-width)/2,
|
|
|
CGRectGetHeight(self.view.frame)+height,
|
|
|
width,
|
|
|
height);
|
|
|
|
|
|
if (self.blurView.superview) {
|
|
|
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideBlurView) object:nil];
|
|
|
[self performSelector:@selector(hideBlurView) withObject:nil afterDelay:2];
|
|
|
} else {
|
|
|
|
|
|
[self.view addSubview:self.blurView];
|
|
|
[UIView animateWithDuration:0.7
|
|
|
delay:0
|
|
|
usingSpringWithDamping:1
|
|
|
initialSpringVelocity:0.5
|
|
|
options:UIViewAnimationOptionCurveEaseInOut
|
|
|
animations:^{
|
|
|
CGPoint center = self.blurView.center;
|
|
|
self.blurView.center = CGPointMake(center.x, CGRectGetHeight(self.view.frame)-height/2);
|
|
|
} completion:^(BOOL finished) {
|
|
|
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(hideBlurView) object:nil];
|
|
|
[self performSelector:@selector(hideBlurView) withObject:nil afterDelay:2];
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
// 从url加载图片
|
|
|
NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrl]];
|
|
|
self.displayPictureView.image = [UIImage imageWithData:imageData scale:0];
|
|
|
}
|
|
|
|
|
|
- (void)hideBlurView {
|
|
|
[UIView animateWithDuration:0.7
|
|
|
delay:0
|
|
|
usingSpringWithDamping:1
|
|
|
initialSpringVelocity:0.5
|
|
|
options:UIViewAnimationOptionCurveEaseInOut
|
|
|
animations:^{
|
|
|
CGPoint center = self.blurView.center;
|
|
|
self.blurView.center = CGPointMake(center.x, CGRectGetHeight(self.view.frame)+CGRectGetHeight(self.blurView.frame)/2);
|
|
|
} completion:^(BOOL finished) {
|
|
|
[self.blurView removeFromSuperview];
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
@end |
...
|
...
|
|