Animate the gradient on the status bar

Source: Internet
Author: User

Animate the gradient on the status bar

Effect

Description

1. Tips to display information on the status bar and overwrite status bar information

2. This design supports external message view customization, only need to implement the prescribed protocol method can

Source

Https://github.com/YouXianMing/StatusBarMessage

////StatusMessage.h//Statusbarview////Created by youxianming on 15/7/24.//Copyright (c) 2015 youxianming. All rights reserved.//#import<UIKit/UIKit.h>#import "StatusMessageProtocol.h"@interfaceStatusmessage:uiview/** * Display loaded View * * @param view implements STATUSMESSAGEPROTOCOL View * @param duration animation display time*/+ (void) Showwithview: (UIView <StatusMessageProtocol> *) View Duration: (nstimeinterval) duration;/** * Hide Loaded View * * @param duration hidden animation display time*/+ (void) Hidewithduration: (nstimeinterval) duration;////////////////////////////////////////////////////////////////////////////////////////////////////** * set display and hidden animation time (not set, default is 1s) * * @param duration animation time*/+ (void) Showandhideduration: (nstimeinterval) duration;/** * Display view, then hidden after a few seconds * * @param view implements Statusmessageprotocol View * @param seconds delay after a few seconds to hide*/+ (void) Showwithview: (uiview<statusmessageprotocol> *) View Hideafterseconds: (nstimeinterval) seconds;@end
////STATUSMESSAGE.M//Statusbarview////Created by youxianming on 15/7/24.//Copyright (c) 2015 youxianming. All rights reserved.//#import "StatusMessage.h"#defineStatus_message @ "StatusMessage"StaticUIWindow *_statuswindow =Nil;StaticNsmaptable *_weakdictionary =Nil;StaticNstimeinterval _animationduration =1. F;@implementationStatusMessage+ (void) Initialize {if(self = = [StatusMessageclass]) {_weakdictionary=[nsmaptable strongtoweakobjectsmaptable]; _statuswindow=[[UIWindow alloc] initwithframe:status_bar_frame]; _statuswindow.windowlevel= Uiwindowlevelstatusbar +1; _statuswindow.userinteractionenabled=NO;    [_statuswindow makekeyandvisible]; }}+ (void) Showwithview: (UIView <StatusMessageProtocol> *) View Duration: (nstimeinterval) Duration {[_weakdictionary setobject:view forkey:status_message];    [_statuswindow Addsubview:view]; [View showwithduration:duration];}+ (void) Hidewithduration: (nstimeinterval) duration {UIView<StatusMessageProtocol> *tmpview =[_weakdictionary Objectforkey:status_message]; [Tmpview hidewithduration:duration];}+ (void) Showandhideduration: (nstimeinterval) duration {_animationduration=duration;}+ (void) Showwithview: (uiview<statusmessageprotocol> *) View Hideafterseconds: (nstimeinterval) seconds {[_weakdictionary setobject:view forkey:status_message];    [_statuswindow Addsubview:view];        [View Showwithduration:_animationduration]; Dispatch_after (Dispatch_time (dispatch_time_now, Seconds* nsec_per_sec), Dispatch_get_main_queue (), ^{UIView<StatusMessageProtocol> *tmpview =[_weakdictionary Objectforkey:status_message];    [Tmpview hidewithduration:_animationduration]; });}@end
////StatusMessageProtocol.h//Statusbarview////Created by youxianming on 15/7/24.//Copyright (c) 2015 youxianming. All rights reserved.//#import<Foundation/Foundation.h>/** * The frame value of the status bar*/#defineStatus_bar_frame [[UIApplication sharedapplication] statusbarframe]@protocolStatusmessageprotocol <NSObject>@required/** * Show Animation * * @param seconds Show duration*/- (void) Showwithduration: (nstimeinterval) seconds;/** * Hide the animation (remove yourself when you hide the animation) * * @param seconds hidden duration*/- (void) Hidewithduration: (nstimeinterval) seconds;@end

Animate the gradient on the status bar

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.