{"id":1047,"date":"2017-04-19T17:22:53","date_gmt":"2017-04-19T09:22:53","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=1047"},"modified":"2017-04-19T17:22:53","modified_gmt":"2017-04-19T09:22:53","slug":"ios%e5%bc%80%e5%8f%91webview%e6%98%be%e7%a4%ba%e5%8a%a0%e8%bd%bd%e8%bf%9b%e5%ba%a6%e6%9d%a1","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/project\/2017\/04\/19\/1722531047.html","title":{"rendered":"iOS\u5f00\u53d1webView\u663e\u793a\u52a0\u8f7d\u8fdb\u5ea6\u6761"},"content":{"rendered":"<p>1\u3001\u4e0a\u56fe\u770b\u6548\u679c\uff0cSafari\u5728\u52a0\u8f7d\u7f51\u9875\u65f6\uff0c\u7f51\u9875\u4e0a\u9762\u4f1a\u6709\u4e00\u4e2a\u84dd\u8272\u8fdb\u5ea6\u6761\uff1b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.yusian.com\/blog\/wp-content\/uploads\/2017\/04\/Simulator-Screen-Shot-2017\u5e744\u670819\u65e5-\u4e0b\u53484.56.25.jpg\" alt=\"\" width=\"320\" height=\"568\" class=\"alignnone size-full wp-image-1048\" \/><\/p>\n<p>2\u3001\u8bbe\u8ba1\u8bf4\u660e\uff1b<br \/>\n2.1\u3001\u5176\u5b9e\u8fd9\u4e2a\u8fdb\u5ea6\u6761\u662f\u5047\u7684\uff0c\u53ea\u662f\u4e00\u4e2a\u52a8\u753b\u64ad\u653e\u800c\u5df2\uff0c\u5c31\u76ee\u524dwebview\u7684\u529f\u80fd\uff0c\u6839\u672c\u65e0\u6cd5\u77e5\u9053\u5f53\u524d\u7f51\u9875\u7684\u52a0\u8f7d\u8fdb\u5ea6\uff0c\u6240\u4ee5\u8fd9\u4e1c\u897f\u662f\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\u7684\uff0c\u8ba9\u7528\u6237\u89c9\u5f97\u201c\u597d\u50cf\u201d\u6b63\u5728\u52aa\u529b\u52a0\u8f7d\u4e2d\u2026\u2026\uff1b<br \/>\n2.2\u3001\u8be5\u529f\u80fd\u7684\u5b9e\u73b0\u4f7f\u7528CASharpLayer\uff0c\u901a\u8fc7\u8d1d\u8d5b\u5c14\u66f2\u7ebf\u586b\u5145\u914d\u5408strokeEnd\u5c5e\u6027\u6a21\u62df\u8fdb\u5ea6\uff1b<br \/>\n2.3\u3001\u5b9a\u4e49\u4e00\u4e2a\u8ba1\u65f6\u5668\uff0c\u901a\u8fc7\u8ba1\u65f6\u5668\u7684\u5faa\u73af\u65b9\u6cd5\u8c03\u7528\uff0c\u5c06strokeEnd\u503c\u901a\u8fc7\u67d0\u4e2a\u7b97\u6cd5\u4ece0-1\u5faa\u73af\u4fee\u6539\u5373\u53ef\uff1b<\/p>\n<p>2\u3001\u90e8\u5206\u4ee3\u7801<\/p>\n<pre line=\"1\" lang=\"objc\">@implementation SAProgressLayer\n\n- (instancetype)init\n{\n    if (self = [super init]){\n        self.strokeColor = SABlueColor.CGColor;\n        UIBezierPath *path = [UIBezierPath bezierPath];\n        [path moveToPoint:CGPointMake(0, 1)];\n        [path addLineToPoint:CGPointMake(SAScreenSize.width, 1)];\n        self.strokeEnd = 0.1f;\n        self.lineWidth = 2.0f;\n        self.path = path.CGPath;\n    }\n    return self;\n}\n#pragma mark - \u57fa\u672c\u65b9\u6cd5\n\/\/ \u5f00\u59cb\u52a0\u8f7d\u52a8\u753b\n- (void)start\n{\n    self.hidden = NO;\n    [self.timer start];\n}\n\/\/ \u7ed3\u675f\u52a0\u8f7d\n- (void)stop\n{\n    [self.timer stop];\n    self.strokeEnd = 1.1f;\n    [SATool delay:0.5 withBlock:^{\n        self.hidden = YES;\n    }];\n}\n#pragma mark - \u61d2\u52a0\u8f7d\n- (SATimer *)timer\n{\n    if (self->_timer == nil){\n        SABlockSelf blockself = self;\n        self->_timer = [SATimer timeWithInterval:0.1 repeatCount:NSIntegerMax block:^(NSUInteger remainCount) {\n            blockself.strokeEnd += (0.8 - blockself.strokeEnd) * 0.05;\n        }];\n    }\n    return self->_timer;\n}\n\n@end<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u4e0a\u56fe\u770b\u6548\u679c\uff0cSafari\u5728\u52a0\u8f7d\u7f51\u9875\u65f6\uff0c\u7f51\u9875\u4e0a\u9762\u4f1a\u6709\u4e00\u4e2a\u84dd\u8272\u8fdb\u5ea6\u6761\uff1b 2\u3001\u8bbe\u8ba1\u8bf4\u660e\uff1b 2.1\u3001\u5176\u5b9e\u8fd9\u4e2a\u8fdb\u5ea6\u6761\u662f\u5047\u7684\uff0c\u53ea\u662f\u4e00\u4e2a\u52a8\u753b\u64ad\u653e\u800c\u5df2\uff0c\u5c31\u76ee\u524dwebview\u7684\u529f\u80fd\uff0c\u6839\u672c\u65e0\u6cd5\u77e5\u9053\u5f53\u524d\u7f51\u9875\u7684\u52a0\u8f7d\u8fdb\u5ea6\uff0c\u6240\u4ee5\u8fd9\u4e1c\u897f\u662f\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\u7684\uff0c\u8ba9\u7528\u6237\u89c9\u5f97\u201c\u597d\u50cf\u201d\u6b63\u5728\u52aa\u529b\u52a0\u8f7d\u4e2d\u2026\u2026\uff1b 2.2\u3001\u8be5\u529f\u80fd\u7684\u5b9e\u73b0\u4f7f\u7528CASharpLayer\uff0c\u901a\u8fc7\u8d1d\u8d5b\u5c14\u66f2\u7ebf\u586b\u5145\u914d\u5408strokeEnd\u5c5e\u6027\u6a21\u62df\u8fdb\u5ea6\uff1b 2.3\u3001\u5b9a\u4e49\u4e00\u4e2a\u8ba1\u65f6\u5668\uff0c\u901a\u8fc7\u8ba1\u65f6\u5668\u7684\u5faa\u73af\u65b9\u6cd5\u8c03\u7528\uff0c\u5c06strokeEnd\u503c\u901a\u8fc7\u67d0\u4e2a\u7b97\u6cd5\u4ece0-1\u5faa\u73af\u4fee\u6539\u5373\u53ef\uff1b 2\u3001\u90e8\u5206\u4ee3\u7801 @implementation SAProgressLayer &#8211; (instancetype)init { if (self = [super init]){ self.strokeColor = SABlueColor.CGColor; UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:CGPointMake(0, 1)]; [path addLineToPoint:CGPointMake(SAScreenSize.width, 1)]; self.strokeEnd = 0.1f; self.lineWidth = 2.0f; self.path = path.CGPath; } return self; } #pragma mark &#8211; \u57fa\u672c\u65b9\u6cd5 \/\/ \u5f00\u59cb\u52a0\u8f7d\u52a8\u753b &#8211; (void)start { self.hidden = NO; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[33],"class_list":["post-1047","post","type-post","status-publish","format-standard","hentry","category-project","tag-33"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1047","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=1047"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1047\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=1047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=1047"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=1047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}