IOS real-time modification of top battery bar color

Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="font-size:14px">By sliding the interface, the top statusbarstyle (battery bar) color is modified in real time based on the offset amount. Directly on the Code:</span></p></p><p><p><span style="font-size:14px; color:#ff0000">First set the Info.plist file in the View controller-based status bar appearance this parameter to No.</span></p></p><p><p><span style="font-size:14px">secondly, the style can be set in the proxy method of SCROLLVIEW.</span></p></p><p><p></p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo">-(<span style="color:#c32275">void</span>) scrollviewdidscroll: (<span style="color:#6122ae">uiscrollview</span> *) ScrollView</p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo"></p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo">{</p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo"><span style="color:#539aa4">_content</span> = scrollView. <span style="color:#703daa">Contentoffset</span>. <span style="color:#703daa">y</span>;</p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo; color:rgb(83,154,164)"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo; color:rgb(83,154,164)"><span style="color:#000000"> </span>_navview<span style="color:#000000">.</span> <span style="color:#703daa">Alpha</span> <span style="color:#000000">=</span>_content<span style="color:#000000"> / </span> <span style="color:#0435ff"></span>$<span style="color:#000000">;</span></p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo"><span style="color:#c32275">if</span> (<span style="color:#539aa4">_navview</span>. <span style="color:#703daa">Alpha</span> ><span style="color:#0435ff">0</span>) {</p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo; color:rgb(61,29,129)"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo; color:rgb(61,29,129)"><span style="color:#000000"> </span> <span style="color:#c32275">return</span> <span style="color:#000000"> [[</span><span style="color:#6122ae">uiapplication</span><span style="color:#000000"></span>sharedapplication<span style="color:#000000">] </span>Setstatusbarstyle <span style="color:#000000">:</span> Uistatusbarstyledefault<span style="color:#000000"></span>animated<span style="color:#000000">:</span><span style="color:#c32275">NO</span><span style="color:#000000">];//black</span></p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo">}</p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo; color:rgb(61,29,129)"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo; color:rgb(61,29,129)"><span style="color:#000000"> </span> <span style="color:#c32275">return</span> <span style="color:#000000"> [[</span><span style="color:#6122ae">uiapplication</span><span style="color:#000000"></span>sharedapplication<span style="color:#000000">] </span>Setstatusbarstyle <span style="color:#000000">:</span> Uistatusbarstylelightcontent<span style="color:#000000"></span>animated<span style="color:#000000">:</span><span style="color:#c32275">NO</span><span style="color:#000000">];//white</span></p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo">}</p></p><br><span style="color:#ff0000"><span style="color:#ff0000">It is important to note that if your previous interface and the next interface do not need to change the battery color, you need to use the Viewwillappear method in the previous interface and next Interface.</span></span><span style="color:#ff0000">Set the color of <span style="color:#ff0000">the battery bar to its original Color. </span></span><span style="color:#ff0000"><span style="color:#ff0000"><br></span></span><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo">-(<span style="color:#c32275">void</span>) viewwillappear: (<span style="color:#c32275">BOOL</span>) animated</p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo">{</p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo">[<span style="color:#c32275">Super</span><span style="color:#3d1d81">viewwillappear</span>: animated];</p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:‘Heiti SC Light‘; color:rgb(29,148,33)"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:‘Heiti SC Light‘; color:rgb(29,148,33)"><span style="font-family:Menlo; color:rgb(0,0,0)"> </span> <span style="font-family:Menlo">//</span> set the battery bar to Black</p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo; color:rgb(61,29,129)"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo; color:rgb(61,29,129)"><span style="color:#000000">[[</span><span style="color:#6122ae">uiapplication</span><span style="color:#000000"></span>sharedapplication<span style="color:#000000">] </span>setstatusbarstyle<span style="color:#000000">:</span> Uistatusbarstyledefault<span style="color:#000000"></span>animated<span style="color:#000000">:</span><span style="color:#c32275">NO</span><span style="color:#000000">];</span></p></p><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo; min-height:19px"><p style="margin-top:0px; margin-bottom:0px; font-size:16px; font-family:Menlo; min-height:19px">}</p></p><br><br><br><br><p><p>IOS real-time modification of top battery bar color</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.