{"id":291,"date":"2015-06-26T17:49:14","date_gmt":"2015-06-26T09:49:14","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=291"},"modified":"2016-07-15T17:36:56","modified_gmt":"2016-07-15T09:36:56","slug":"ios%e5%bc%80%e5%8f%91%e4%b8%ad%e8%8f%8a%e8%8a%b1%e7%9a%84%e4%bd%bf%e7%94%a8%ef%bc%88uiactivityindicatorview%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/project\/2015\/06\/26\/174914291.html","title":{"rendered":"iOS\u5f00\u53d1\u4e2d\u83ca\u82b1\u7684\u4f7f\u7528\uff08UIActivityIndicatorView\uff09"},"content":{"rendered":"<p>1\u3001\u8001\u89c4\u77e9\uff0c\u5148\u4e0a\u56fe<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-292\" src=\"http:\/\/www.yusian.com\/blog\/wp-content\/uploads\/2016\/07\/iOS-Simulator-Screen-Shot-2015\u5e746\u670826\u65e5-\u4e0b\u53485.02.50.png\" alt=\"iOS-Simulator-Screen-Shot-2015\u5e746\u670826\u65e5-\u4e0b\u53485.02.50\" width=\"320\" height=\"568\" \/><\/p>\n<p><strong>2\u3001\u57fa\u672c\u4f7f\u7528<\/strong><\/p>\n<p>2.1\u3001\u521d\u59cb\u5316<br \/>\n<span style=\"font-family: Arial;\"><span style=\"color: #ff0000;\">UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];<\/span><br \/>\n\u7cfb\u7edf\u9ed8\u8ba4\u6709\u4e09\u79cd\u7c7b\u578b\u53ef\u9009\uff0c\u4e3b\u8981\u662f\u5927\u5c0f\u989c\u8272\u533a\u522b<!--more--><br \/>\ntypedef NS_ENUM(NSInteger, UIActivityIndicatorViewStyle) {<br \/>\nUIActivityIndicatorViewStyleWhiteLarge,<br \/>\nUIActivityIndicatorViewStyleWhite,<br \/>\nUIActivityIndicatorViewStyleGray,<br \/>\n};<\/span><\/p>\n<p>2.2\u3001\u8bbe\u7f6e\u4f4d\u7f6e<br \/>\n<span style=\"font-family: Arial;\"><span style=\"color: #ff0000;\">CGSize size = self.view.bounds.size;<br \/>\nCGFloat x = size.width * 0.5;<br \/>\nCGFloat y = size.height * 0.5;<br \/>\n[loading setCenter:CGPointMake(x, y)];<\/span><\/span><br \/>\nUIActivityIndicatorView\u53ea\u80fd\u8bbe\u7f6e\u4e2d\u5fc3\u70b9\uff0c\u4e0d\u80fd\u8bbe\u7f6e\u5927\u5c0f<\/p>\n<p>2.3\u3001\u663e\u793a\/\u9690\u85cf<br \/>\n<span style=\"font-family: Arial;\"><span style=\"color: #ff0000;\">[loading startAnimating];<br \/>\n[loading stopAnimating];<\/span><\/span><\/p>\n<p>2.4\u3001\u8bbe\u7f6e\u989c\u8272<br \/>\n<span style=\"font-family: Arial;\"><span style=\"color: #ff0000;\">[loading setColor:[UIColor redColor]];<\/span><\/span><\/p>\n<p>2.5\u3001\u6dfb\u52a0\u63a7\u4ef6<br \/>\n<span style=\"font-family: Arial;\"><span style=\"color: #ff0000;\">[self.view addSubView:loading]<\/span><\/span><\/p>\n<p><strong>3\u3001\u4f7f\u7528\u573a\u666f<\/strong><br \/>\n\u6bd4\u5982\u5728WebView\u4e0a\u4f7f\u7528\uff0c\u53ef\u5728WebView\u7684\u4e24\u4e2a\u4ee3\u7406\u65b9\u6cd5\u4e2d\u5b9e\u73b0\u81ea\u52a8\u663e\u793a\u6216\u9690\u85cf<br \/>\n<span style=\"font-family: Arial;\"><span style=\"color: red;\">&#8211; (void)webViewDidStartLoad:(UIWebView *)webView<br \/>\n{<br \/>\n[self.loading startAnimating];<br \/>\n}<\/p>\n<p>&#8211; (void)webViewDidFinishLoad:(UIWebView *)webView{<br \/>\n[self.loading stopAnimating];<br \/>\n}<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u8001\u89c4\u77e9\uff0c\u5148\u4e0a\u56fe 2\u3001\u57fa\u672c\u4f7f\u7528 2.1\u3001\u521d\u59cb\u5316 UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; \u7cfb\u7edf\u9ed8\u8ba4\u6709\u4e09\u79cd\u7c7b\u578b\u53ef\u9009\uff0c\u4e3b\u8981\u662f\u5927\u5c0f\u989c\u8272\u533a\u522b<\/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":[20],"class_list":["post-291","post","type-post","status-publish","format-standard","hentry","category-project","tag-basics"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/291","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=291"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/291\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}