{"id":357,"date":"2015-05-22T23:03:39","date_gmt":"2015-05-22T15:03:39","guid":{"rendered":"http:\/\/www.yusian.com\/blog\/?p=357"},"modified":"2016-07-15T17:19:04","modified_gmt":"2016-07-15T09:19:04","slug":"%e5%85%b3%e4%ba%8euiview%e7%9a%84alpha%e5%b1%9e%e6%80%a7%e7%9a%84%e6%8e%a2%e8%ae%a8","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/project\/2015\/05\/22\/230339357.html","title":{"rendered":"\u5173\u4e8eUIView\u7684alpha\u5c5e\u6027\u7684\u63a2\u8ba8"},"content":{"rendered":"<p>1\u3001UIView\u7684alpha\u5c5e\u6027\u6307\u7684\u662f\u89c6\u56fe\u7684\u900f\u660e\u5ea6\uff0c\u8be5\u5c5e\u6027\u503c\u53d6\u503c0~1\uff0c\u5982\u679c\u4e3a0\u5219\u8bf4\u660e\u89c6\u56fe\u4e3a\u5168\u900f\u660e\uff0c\u5982\u679c\u4e3a1\u5219\u5b8c\u5168\u4e0d\u900f\u660e\uff0c\u6211\u4eec\u901a\u8fc7\u793a\u4f8b\u6765\u8bf4\u660e\u95ee\u9898\uff0c\u5148\u770b\u539f\u6548\u679c\u56fe<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.yusian.com\/blog\/wp-content\/uploads\/2016\/07\/iOS-Simulator-Screen-Shot-2015\u5e745\u670822\u65e5-\u4e0b\u534810.45.32.png\" alt=\"iOS Simulator Screen Shot 2015\u5e745\u670822\u65e5 \u4e0b\u534810.45.32\" width=\"320\" height=\"480\" class=\"alignnone size-full wp-image-358\" \/><\/p>\n<p>\u8be5\u7a97\u53e3\u4e0a\u4e00\u5171\u67094\u4e2aView\uff0c\u6700\u5e95\u5c42\u4e3a\u98ce\u666f\u56fe\uff0c\u98ce\u666f\u56fe\u4e0a\u9762\u4e3a\u4e00\u4e2a\u7ea2\u8272\u7684View\uff0c\u7ea2\u8272View\u4e0a\u9762\u6709\u4e24\u4e2a\u5b50View\uff0c\u5206\u522b\u4e3a\u84dd\u8272View\u548c\u7eff\u8272View\uff0c\u7531\u4e8e\u7ea2\u8272\u5b8c\u5168\u538b\u5728\u98ce\u666f\u56fe\u4e0a\u9762\uff0c\u6240\u4ee5\u770b\u4e0d\u5230\u98ce\u666f\u56fe\u3002<br \/>\n\u5c42\u7ea7\u5173\u7cfb\u4e3a<br \/>\n&#8212;UIImageView<br \/>\n&#8212;&#8211;UIView\uff08redView\uff09<br \/>\n&#8212;&#8212;-UIView\uff08greenView\uff09<br \/>\n&#8212;&#8212;-UIView\uff08blueView\uff09<\/p>\n<p>2\u3001\u95ee\u9898\u6765\u4e86\uff0credView\u4e0a\u9762\u8fd8\u6709\u5b50\u89c6\u56feblueView\u548cgreenView\uff0c\u90a3\u4e48\u8bbe\u7f6e\u8be5redView\u7684alpha\u5c5e\u6027\uff0c\u5b50\u89c6\u56fe\u4f1a\u600e\u6837\uff1f\u6211\u4eec\u6765\u8bbe\u7f6e\u4e00\u4e0b\uff0c\u4ee3\u7801\uff1a<!--more--><\/p>\n<pre lang=\"objc\" line=\"1\">self.redView.backgroundColor = [UIColor colorWithRed:1.0 green:0 blue:0 alpha:1.0];\nself.greenView.backgroundColor = [UIColor colorWithRed:0 green:1.0 blue:0 alpha:1.0];\nself.blueView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:1.0 alpha:1.0];\nself.redView.alpha = 0.5;<\/pre>\n<p>\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.yusian.com\/blog\/wp-content\/uploads\/2016\/07\/iOS-Simulator-Screen-Shot-2015\u5e745\u670822\u65e5-\u4e0b\u534810.45.47.png\" alt=\"iOS Simulator Screen Shot 2015\u5e745\u670822\u65e5 \u4e0b\u534810.45.47\" width=\"320\" height=\"480\" class=\"alignnone size-full wp-image-359\" \/><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u770b\u5230redView\u7684\u900f\u660e\u5ea6\u8bbe\u7f6e\u4e3a0.5\u65f6\uff0credView\u4ee5\u53ca\u5b50\u89c6\u56fegreenView\u3001blueView\u7684\u900f\u660e\u5ea6\u5747\u53d8\u4e3a\u4e860.5\uff0c\u9690\u7ea6\u53ef\u4ee5\u770b\u5230\u6700\u4e0b\u9762\u7684\u98ce\u666f\u56fe\u4e86\u3002<\/p>\n<p>3\u3001\u5982\u679c\u6211\u4eec\u53ea\u5e0c\u671bredView\u534a\u900f\u660e\uff0c\u800cblueView\u4e0egreenView\u4e0d\u5e0c\u671b\u53d8\u900f\u660e\uff0c\u8be5\u5982\u4f55\u5904\u7406\u5462\uff1f<br \/>\n3.1\u3001\u7b2c\u4e00\u79cd\u65b9\u5f0f\uff0c\u5c06blueView\u4e0egreenView\u8bbe\u7f6e\u4e3a\u80cc\u666f\u7684\u5b50\u89c6\u56fe\uff0c\u8131\u79bb\u4e0eredView\u7684\u7236\u5b50\u5173\u7cfb\uff0c\u8fd9\u6837\u5c31\u4e0d\u4f1a\u53d7\u7236\u63a7\u4ef6\u7684\u5f71\u54cd\uff0c\u8fd9\u6837\u5904\u7406\u4ece\u67d0\u79cd\u7a0b\u5ea6\u4e0a\u6765\u8bb2\u4f3c\u4e4e\u89e3\u51b3\u4e86\u95ee\u9898\uff0c\u4f46\u7ec8\u7a76\u6539\u53d8\u4e86\u539f\u6709\u7684\u7ed3\u6784\uff0c\u6240\u4ee5\u4e0d\u592a\u7406\u60f3\u3002<br \/>\n3.2\u3001\u7b2c\u4e8c\u79cd\u65b9\u5f0f\uff0c\u5982\u679c\u53ea\u5e0c\u671bredView\u534a\u900f\u660e\uff0c\u9664\u4e86\u8bbe\u7f6eredView\u7684alpha\u5c5e\u6027\u5916\uff0c\u5728\u989c\u8272\u586b\u5145\u7684\u65f6\u5019\u4e5f\u53ef\u4ee5\u8bbe\u7f6e\u900f\u660e\uff0c\u8fd9\u662f\u6211\u8fd9\u6b21\u9700\u8981\u8bf4\u660e\u7684\u91cd\u70b9\uff0c\u770b\u4e0b\u9762\u4ee3\u7801<\/p>\n<pre lang=\"objc\" line=\"1\">self.redView.backgroundColor = [UIColor colorWithRed:1.0 green:0 blue:0 alpha:0.5];\nself.greenView.backgroundColor = [UIColor colorWithRed:0 green:1.0 blue:0 alpha:1.0];\nself.blueView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:1.0 alpha:1.0];\nself.redView.alpha = 1.0;<\/pre>\n<p>\u5173\u952e\u6027\u7684\u4e00\u53e5\uff1aself.redView.backgroundColor = [UIColor colorWithRed:1.0 green:0 blue:0 alpha:0.5]<br \/>\n\u770b\u6548\u679c\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.yusian.com\/blog\/wp-content\/uploads\/2016\/07\/iOS-Simulator-Screen-Shot-2015\u5e745\u670822\u65e5-\u4e0b\u534810.46.40.png\" alt=\"iOS Simulator Screen Shot 2015\u5e745\u670822\u65e5 \u4e0b\u534810.46.40\" width=\"320\" height=\"480\" class=\"alignnone size-full wp-image-360\" \/><\/p>\n<p>4\u3001\u8bdd\u4e0d\u591a\u8bf4\uff0c\u6162\u6162\u4f53\u4f1a\uff0c\u8fd9\u5728\u9879\u76ee\u4e2d\u662f\u53ef\u80fd\u7528\u5f97\u4e0a\u7684\uff01\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001UIView\u7684alpha\u5c5e\u6027\u6307\u7684\u662f\u89c6\u56fe\u7684\u900f\u660e\u5ea6\uff0c\u8be5\u5c5e\u6027\u503c\u53d6\u503c0~1\uff0c\u5982\u679c\u4e3a0\u5219\u8bf4\u660e\u89c6\u56fe\u4e3a\u5168\u900f\u660e\uff0c\u5982\u679c\u4e3a1\u5219\u5b8c\u5168\u4e0d\u900f\u660e\uff0c\u6211\u4eec\u901a\u8fc7\u793a\u4f8b\u6765\u8bf4\u660e\u95ee\u9898\uff0c\u5148\u770b\u539f\u6548\u679c\u56fe \u8be5\u7a97\u53e3\u4e0a\u4e00\u5171\u67094\u4e2aView\uff0c\u6700\u5e95\u5c42\u4e3a\u98ce\u666f\u56fe\uff0c\u98ce\u666f\u56fe\u4e0a\u9762\u4e3a\u4e00\u4e2a\u7ea2\u8272\u7684View\uff0c\u7ea2\u8272View\u4e0a\u9762\u6709\u4e24\u4e2a\u5b50View\uff0c\u5206\u522b\u4e3a\u84dd\u8272View\u548c\u7eff\u8272View\uff0c\u7531\u4e8e\u7ea2\u8272\u5b8c\u5168\u538b\u5728\u98ce\u666f\u56fe\u4e0a\u9762\uff0c\u6240\u4ee5\u770b\u4e0d\u5230\u98ce\u666f\u56fe\u3002 \u5c42\u7ea7\u5173\u7cfb\u4e3a &#8212;UIImageView &#8212;&#8211;UIView\uff08redView\uff09 &#8212;&#8212;-UIView\uff08greenView\uff09 &#8212;&#8212;-UIView\uff08blueView\uff09 2\u3001\u95ee\u9898\u6765\u4e86\uff0credView\u4e0a\u9762\u8fd8\u6709\u5b50\u89c6\u56feblueView\u548cgreenView\uff0c\u90a3\u4e48\u8bbe\u7f6e\u8be5redView\u7684alpha\u5c5e\u6027\uff0c\u5b50\u89c6\u56fe\u4f1a\u600e\u6837\uff1f\u6211\u4eec\u6765\u8bbe\u7f6e\u4e00\u4e0b\uff0c\u4ee3\u7801\uff1a<\/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-357","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\/357","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=357"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/357\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}