ZFWKWebView 1.2.2

ZFWKWebView 1.2.2

Franlucky维护。



  • Pokeey

ICU-Coders

MIT Build Status podversion Platform

ZFWKWebView 是一个高度可定制的WKWebView,适用于iOS。在您的下一个项目中选择 ZFWKWebView,或者将现有项目迁移过来——您将会对所做的选择感到满意!

ZFWKWebView 添加到您的项目中

CocoaPods

CocoaPods 是向您的项目添加 ZFWKWebView 的推荐方式。在您的Podfile中指定它。

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

target 'TargetName' do
pod 'ZFWKWebView', '~> 1.2.2'
end

然后运行以下命令:

pod install --repo-update

源文件

除了以上方法,您也可以直接将 ZFWKWebView.hZFWKWebView.m 源文件添加到项目中。

  1. 下载最新的代码版本(最新版本),或将仓库作为git子模块添加到git跟踪的项目中。
  2. 在Xcode中打开您的项目,然后将ZFWKWebView.hZFWKWebView.m文件拖拽到项目中(使用“产品导航器视图”)。如果代码存档是在项目外提取的,确保选择“复制项目中的文件”。
  3. 使用#import "ZFWKWebView.h"在任何需要的地方包含ZFWKWebView

使用方法

自定义配置

ZFWKWebVCConf 继承配置

@interface ZFWKUserDefaultConf : ZFWKWebVCConf
ZFWKUserDefaultConf *userConf = [[ZFWKUserDefaultConf alloc] init];
ZFWKWebVC *web = [[ZFWKWebVC alloc] initWithConf:userConf];

默认配置

ZFWKWebVC *web = [[ZFWKWebVC alloc] initWithDefaultConfig];
[web.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.apple.com.cn"]]];
[self presentViewController:web animated:YES completion:nil];

注册js或事件配置

正文是序列化响应

[self addMethodName:ZFWKWebViewEventCloseKey callback:^(ZFWKWebVC * _Nonnull target, ZFWKWebVCConf * _Nonnull config, id  _Nullable body) {
    
}];

自定义事件键

ZFWKWebViewEventStartLoadKey 
ZFWKWebViewEventStartRecevicedKey 
ZFWKWebViewEventFinishRecevicedKey 
ZFWKWebViewEventLoadFailedKey 
ZFWKWebViewEventRefreshKey 
ZFWKWebViewEventCloseKey 
ZFWKWebViewEventRightButtonClickKey 
ZFWKWebViewEventGoBackKey 
ZFWKWebViewEventGoForwardKey 

评估JavaScript

[webVC evaluateJavaScriptMethodName:@"test" params:@{} callback:^(id _Nullable, NSError * _Nullable error) {
    
}];

自定义UI

图片很丑,但ZFWKWebView确实很灵活。

Custom_UI

self.titleFont = [UIFont systemFontOfSize:33 weight:UIFontWeightBold];
self.titleColor = [UIColor redColor];
self.navigationBackgroundColor = [UIColor greenColor];

self.showRightNavigationButton = YES;
self.rightNavigationButtonTitle = @"Skip";
self.rightNavigationButtonTextFont = [UIFont systemFontOfSize:13 weight:UIFontWeightRegular];
self.rightNavigationButtonTextColor = [UIColor yellowColor];

self.progressBarHeight = 40;
self.progressTintColor = [UIColor colorWithRed:86/255.0 green:187/255.0 blue:59/255.0 alpha:1];
self.progressBackgroundColor = [UIColor clearColor];

自定义进度条

Custom_progress_bar

ZFWKUserDefaultConf *userConf = [[ZFWKUserDefaultConf alloc] init];
userConf.progressBarHeight = 40;
userConf.progressTintColor = [UIColor colorWithRed:86/255.0 green:187/255.0 blue:59/255.0 alpha:1];
userConf.progressBackgroundColor = [UIColor clearColor];

显示底部栏

Custom_UI

self.showBottomBar = YES;
self.showCloseButton = NO; 

MIT 许可证

版权所有 (c) 2019 Pokeey

本许可证无条件地授予任何获得此软件及其相关文档副本(统称“软件”)的人,在不受限制的情况下处理和使用软件,包括但不限于使用、复制、修改、合并、发布、分发、 子许可和/或销售软件副本,并允许软件使用者进行上述操作,前提是遵守以下条件

上述版权声明和本许可声明应包含在软件副本或实质部分中。

软件按“现状”提供,不提供任何形式(明示或暗示)的保证,包括但不限于适销性、适用于特定用途和无侵权性的保证。在任何情况下,作者或版权所有者不对任何索赔、损害或其他责任负责,无论该责任源于合同、侵权或其他原因,由软件本身、使用或与其他软件或其用途相关的任何行为引起。