在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:AXWebViewController开源软件地址:https://gitee.com/3Liang/AXWebViewController开源软件介绍:AXWebViewController##Summary Features
Requirements
使用的时候最好使用最新版Xcode。 Adding AXWebViewController to your projetCocoaPodsCocoaPods is the recommended way to add AXWebViewController to your project.
Source filesAlternatively you can directly add the
LicenseThis code is distributed under the terms and conditions of the MIT license. Usage
AXWebViewController *webVC = [[AXWebViewController alloc] initWithAddress:@"http://www.baidu.com"];webVC.showsToolBar = NO;webVC.navigationController.navigationBar.translucent = NO;self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.100f green:0.100f blue:0.100f alpha:0.800f];self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.996f green:0.867f blue:0.522f alpha:1.00f];[self.navigationController pushViewController:webVC animated:YES]; 使用工具条导航使用工具条只需在 webVC.navigationType = AXWebViewControllerNavigationToolItem;webVC.showsToolBar = YES; 注意,在设置 使用微信样式导航在 webVC.navigationType = AXWebViewControllerNavigationBarItem; 即可生效. Peek&PopPeek和Pop使用的是原生的系统功能,在使用的时候只需要将 - (void)hookWebContentCommitPreviewHandler { // Find the `WKContentView` in the webview. __weak typeof(self) wself = self; for (UIView *_view in _webView.scrollView.subviews) { if ([_view isKindOfClass:NSClassFromString(@"WKContentView")]) { id _previewItemController = object_getIvar(_view, class_getInstanceVariable([_view class], "_previewItemController")); Class _class = [_previewItemController class]; SEL _performCustomCommitSelector = NSSelectorFromString(@"previewInteractionController:interactionProgress:forRevealAtLocation:inSourceView:containerView:"); [_previewItemController aspect_hookSelector:_performCustomCommitSelector withOptions:AspectPositionAfter usingBlock:^() { UIViewController *pred = [_previewItemController valueForKeyPath:@"presentedViewController"]; [pred aspect_hookSelector:NSSelectorFromString(@"_addRemoteView") withOptions:AspectPositionAfter usingBlock:^() { UIViewController *_remoteViewController = object_getIvar(pred, class_getInstanceVariable([pred class], "_remoteViewController")); [_remoteViewController aspect_hookSelector:@selector(viewDidLoad) withOptions:AspectPositionAfter usingBlock:^() { _remoteViewController.view.tintColor = wself.navigationController.navigationBar.tintColor; } error:NULL]; } error:NULL]; NSArray *ddActions = [pred valueForKeyPath:@"ddActions"]; id openURLAction = [ddActions firstObject]; [openURLAction aspect_hookSelector:NSSelectorFromString(@"perform") withOptions:AspectPositionInstead usingBlock:^ () { NSURL *_url = object_getIvar(openURLAction, class_getInstanceVariable([openURLAction class], "_url")); [wself loadURL:_url]; } error:NULL]; id _lookupItem = object_getIvar(_previewItemController, class_getInstanceVariable([_class class], "_lookupItem")); [_lookupItem aspect_hookSelector:NSSelectorFromString(@"commit") withOptions:AspectPositionInstead usingBlock:^() { NSURL *_url = object_getIvar(_lookupItem, class_getInstanceVariable([_lookupItem class], "_url")); [wself loadURL:_url]; } error:NULL]; [_lookupItem aspect_hookSelector:NSSelectorFromString(@"commitWithTransitionForPreviewViewController:inViewController:completion:") withOptions:AspectPositionInstead usingBlock:^() { NSURL *_url = object_getIvar(_lookupItem, class_getInstanceVariable([_lookupItem class], "_url")); [wself loadURL:_url]; } error:NULL]; /* UIWindow -UITransitionView --UIVisualEffectView ---_UIVisualEffectContentView ----UIView -----_UIPreviewActionSheetView */ /* for (UIView * transitionView in [UIApplication sharedApplication].keyWindow.subviews) { if ([transitionView isMemberOfClass:NSClassFromString(@"UITransitionView")]) { transitionView.tintColor = wself.navigationController.navigationBar.tintColor; for (UIView *__view in transitionView.subviews) { if ([__view isMemberOfClass:NSClassFromString(@"UIVisualEffectView")]) { for (UIView *___view in __view.subviews) { if ([___view isMemberOfClass:NSClassFromString(@"_UIVisualEffectContentView")]) { for (UIView *____view in ___view.subviews) { if ([____view isMemberOfClass:NSClassFromString(@"UIView")]) { __weak typeof(____view) w____view = ____view; [____view aspect_hookSelector:@selector(addSubview:) withOptions:AspectPositionAfter usingBlock:^() { for (UIView *actionSheet in w____view.subviews) { if ([actionSheet isMemberOfClass:NSClassFromString(@"_UIPreviewActionSheetView")]) { break; } } } error:NULL]; } }break; } }break; } }break; } } */ } error:NULL]; break; } }} 致谢RxWebViewController为我提供了思路,有些地方做了参考 使用了NJKWebViewProgress作为进度条,感谢! 更新日志0.1.10使用基于 0.2.0iOS8.0以上使用 0.3.0使用AXNavigationBackItemInjection实现微信导航样式,也可以自定义返回的操作,只需要几行代码就可以搞定! |
请发表评论