Some actions of the iOS status bar

Source: Internet
Author: User
<span id="Label3"></p><strong><strong>[cpp]</strong></strong>View plaincopyprint?<object id="ZeroClipboardMovie_1" width="22" height="11" align="middle" bgcolor="#ffffff" data="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash"><object id="ZeroClipboardMovie_1" width="22" height="11" align="middle" bgcolor="#ffffff" data="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash"><param name="src" value="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf"><param name="loop" value="loop"><param name="menu" value="false"><param name="quality" value="best"><param name="allowscriptaccess" value="always"><param name="allowfullscreen" value="false"><param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer"><param name="flashvars" value="id=1&width=22&height=11"><param name="wmode" value="transparent"></object></object> <ol class="dp-cpp" start="1"> <ol class="dp-cpp" start="1"> <li class="alt">[uiapplication sharedapplication].networkactivityindicatorvisible = YES; <span class="comment">//display</span></li> <li>[uiapplication sharedapplication].networkactivityindicatorvisible = NO; <span class="comment">//hide</span></li> </ol> </ol><p><p>Let the status bar display the network wait flag</p></p><p><p></p></p><p><p></p></p><p align="left"><p align="left">The status bar can be modified by some of the methods provided by the UIApplication class, such as completely removing the status bar or modifying the style, but these changes are only within your program and will be restored when you exit your Program.</p></p><p><p></p></p> <ol> <ol> <li>UIApplication *myapp = [uiapplication sharedapplication];</li> </ol> </ol><p align="left"><p align="left">1. Hide the status bar</p></p><p><p></p></p> <ol> <ol> <li>[MYAPP Setstatusbarhidden:yes animated:yes];</li> </ol> </ol>Copy Code<p><p>Remember to hide the status bar after your "desktop" increases the size of the 320x20, so it is best to hide it before any window or view Creation.</p></p><p><p>2. Status bar Style</p></p><p><p></p></p> <ol> <ol> <li>[MYAPP setstatusbarstyle:uistatusbarstyleblackopaque];</li> </ol> </ol> <ol> <ol> <li>typedef enum {</li> <li>uistatusbarstyledefault,</li> <li>uistatusbarstyleblacktranslucent,</li> <li>Uistatusbarstyleblackopaque</li> <li>} uistatusbarstyle;</li> </ol> </ol><p><p>3. Status bar Direction</p></p><p><p></p></p><p><p></p></p> <ol> <ol> <li>[MYAPP Setstatusbarorientation:uiinterfaceorientationlandscapeleft animated:no];</li> </ol> </ol> <ol> <ol> <li>typedef enum {</li> <li>uiinterfaceorientationportrait = uideviceorientationportrait,</li> <li>Portrait screen, Vertical Upward</li> <li>Uiinterfaceorientationportraitupsidedown = uideviceorientationportraitupsidedown,</li> <li>Vertical screen, upside down vertically</li> <li>Uiinterfaceorientationlandscapeleft = uideviceorientationlandscaperight,</li> <li>The device rotates counterclockwise to the horizontal screen mode</li> <li>Uiinterfaceorientationlandscaperight = Uideviceorientationlandscapeleft</li> <li>Device rotates clockwise to horizontal screen mode</li> <li>} uiinterfaceorientation;</li> </ol> </ol><p><p></p></p><p><p>Sometimes it is necessary to display some custom information on the status bar, such as the official iOS client of Sina Weibo: informing the user that the message is in the sending queue, sending it successfully, or failing to send it.</p></p><p><p></p></p><p><p>For example, by displaying custom information in the status bar, you can be user-friendly without compromising the software's use of Hints.</p></p><p><p>To do this, we appear to define a custom status bar class that contains a label that displays information:</p></p><p><p></p></p><strong><strong>[cpp]</strong></strong>View Plaincopy<object id="ZeroClipboardMovie_2" width="18" height="18" align="middle" bgcolor="#ffffff" data="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash"><object id="ZeroClipboardMovie_2" width="18" height="18" align="middle" bgcolor="#ffffff" data="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash"><param name="src" value="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf"><param name="loop" value="loop"><param name="menu" value="false"><param name="quality" value="best"><param name="allowscriptaccess" value="always"><param name="allowfullscreen" value="false"><param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer"><param name="flashvars" value="id=2&width=18&height=18"><param name="wmode" value="transparent"></object></object> <ol class="dp-cpp" start="1"> <ol class="dp-cpp" start="1"> <li class="alt">@interface Customstatusbar:uiwindow</li> <li>{</li> <li class="alt">UILabel *_messagelabel;</li> <li>}</li> <li class="alt"></li> <li>-(<span class="keyword">void) showstatusmessage: (nsstring *) message; </span></li> <li class="alt">-(<span class="keyword">Void) hide; </span></li> <li></li> <li class="alt">@end</li> </ol> </ol><p><p><br>next, set the size to match the system status bar and the background is black:</p></p><p><p></p></p><p><p></p></p><strong><strong>[cpp]</strong></strong>View Plaincopy<object id="ZeroClipboardMovie_3" width="18" height="18" align="middle" bgcolor="#ffffff" data="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash"><object id="ZeroClipboardMovie_3" width="18" height="18" align="middle" bgcolor="#ffffff" data="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash"><param name="src" value="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf"><param name="loop" value="loop"><param name="menu" value="false"><param name="quality" value="best"><param name="allowscriptaccess" value="always"><param name="allowfullscreen" value="false"><param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer"><param name="flashvars" value="id=3&width=18&height=18"><param name="wmode" value="transparent"></object></object> <ol class="dp-cpp" start="1"> <ol class="dp-cpp" start="1"> <li class="alt">Self.frame = [uiapplication sharedapplication].statusbarframe;</li> <li>Self.backgroundcolor = [uicolor blackcolor];</li> </ol> </ol><p><p><br>here, in order for the custom status bar to be visible to the user, it is also necessary to set its windowlevel.</p></p><p><p></p></p><p><p>In ios, the Windowlevel property determines the level of display for UIWINDOW. The default windowlevel is uiwindowlevelnormal, which is 0.0.</p></p><p><p>The system defines three levels as follows, with reference to the official documentation:</p></p><p><p></p></p><strong><strong>[cpp]</strong></strong>View Plaincopy<object id="ZeroClipboardMovie_4" width="18" height="18" align="middle" bgcolor="#ffffff" data="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash"><object id="ZeroClipboardMovie_4" width="18" height="18" align="middle" bgcolor="#ffffff" data="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash"><param name="src" value="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf"><param name="loop" value="loop"><param name="menu" value="false"><param name="quality" value="best"><param name="allowscriptaccess" value="always"><param name="allowfullscreen" value="false"><param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer"><param name="flashvars" value="id=4&width=18&height=18"><param name="wmode" value="transparent"></object></object> <ol class="dp-cpp" start="1"> <ol class="dp-cpp" start="1"> <li class="alt"><span class="keyword">Const Uiwindowlevel uiwindowlevelnormal;</span></li> <li><span class="keyword">Const Uiwindowlevel uiwindowlevelalert;</span></li> <li class="alt"><span class="keyword">Const Uiwindowlevel uiwindowlevelstatusbar;</span></li> <li><span class="keyword">typedef cgfloat uiwindowlevel;</span></li> </ol> </ol><p><p><br>To be able to override the System's default status bar, We windowlevel the custom status Bar:</p></p><p><p></p></p><p><p></p></p><strong><strong>[cpp]</strong></strong>View Plaincopy<object id="ZeroClipboardMovie_5" width="18" height="18" align="middle" bgcolor="#ffffff" data="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash"><object id="ZeroClipboardMovie_5" width="18" height="18" align="middle" bgcolor="#ffffff" data="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash"><param name="src" value="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf"><param name="loop" value="loop"><param name="menu" value="false"><param name="quality" value="best"><param name="allowscriptaccess" value="always"><param name="allowfullscreen" value="false"><param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer"><param name="flashvars" value="id=5&width=18&height=18"><param name="wmode" value="transparent"></object></object> <ol class="dp-cpp" start="1"> <ol class="dp-cpp" start="1"> <li class="alt">Self.windowlevel = Uiwindowlevelstatusbar + 1.0f;</li> </ol> </ol><p><p><br>finally, add a little harmless animation for displaying information and hiding:</p></p><p><p></p></p><p><p></p></p><strong><strong>[cpp]</strong></strong>View Plaincopy<object id="ZeroClipboardMovie_6" width="18" height="18" align="middle" bgcolor="#ffffff" data="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash"><object id="ZeroClipboardMovie_6" width="18" height="18" align="middle" bgcolor="#ffffff" data="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" type="application/x-shockwave-flash"><param name="src" value="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf"><param name="loop" value="loop"><param name="menu" value="false"><param name="quality" value="best"><param name="allowscriptaccess" value="always"><param name="allowfullscreen" value="false"><param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer"><param name="flashvars" value="id=6&width=18&height=18"><param name="wmode" value="transparent"></object></object> <ol class="dp-cpp" start="1"> <li class="alt"><li class="alt">-(<span class="keyword">void) showstatusmessage: (nsstring *) message</span></li></li> <li><li>{</li></li> <li class="alt"><li class="alt">Self.hidden = NO;</li></li> <li><li>Self.alpha = 1.0f;</li></li> <li class="alt"><li class="alt">_messagelabel.text = @<span class="string">""; </span></li></li> <li><li></li></li> <li class="alt"><li class="alt">Cgsize totalsize = self.frame.size;</li></li> <li><li>Self.frame = (cgrect) {self.frame.origin, 0, totalsize.height};</li></li> <li class="alt"><li class="alt"></li></li> <li><li>[UIView animatewithduration:0.5f animations:^{</li></li> <li class="alt"><li class="alt">Self.frame = (cgrect) {self.frame.origin, totalsize};</li></li> <li><li>} completion:^ (<span class="datatypes">BOOL finished) {</span></li></li> <li class="alt"><li class="alt">_messagelabel.text = message;</li></li> <li><li>}];</li></li> <li class="alt"><li class="alt">}</li></li> <li><li></li></li> <li class="alt"><li class="alt">-(<span class="keyword">void) Hide</span></li></li> <li><li>{</li></li> <li class="alt"><li class="alt">Self.alpha = 1.0f;</li></li> <li><li></li></li> <li class="alt"><li class="alt">[UIView animatewithduration:0.5f animations:^{</li></li> <li><li>Self.alpha = 0.0f;</li></li> <li class="alt"><li class="alt">} completion:^ (<span class="datatypes">BOOL finished) {</span></li></li> <li><li>_messagelabel.text = @<span class="string">""; </span></li></li> <li class="alt"><li class="alt">Self.hidden = YES;</li></li> <li><li>}];;</li></li> <li class="alt"><li class="alt">}</li></li> </ol><p><p>Some actions of the iOS status bar</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.