JDStatusBarNotification——状态栏顶部显示通知,iOS 7风格。支持 iOS 6和iOS 7 (在iOS代码库中浏览本帖)
管理提醒:本帖被 ccsupport 执行加亮操作(2013-11-07)
- 关键字:状态栏顶部显示通知
- 代码类库:其他(Others)
- GitHub链接:https://github.com/jaydee3/JDStatusBarNotification
安装
通过CocoaPods
pod 'JDStatusBarNotification'
手动安装
1.将JDStatusBarNotification/JDStatusBarNotification拖到工程中
2.添加#include "JDStatusBarNotification.h"
用法
JDStatusBarNotification是单利模式。不需要初始化,只需要使用以下的类方法:
显示一条通知
1
2
3
|
+ (UIView*)showWithStatus:(
NSString
*)status;
+ (UIView*)showWithStatus:(
NSString
*)status
dismissAfter:(
NSTimeInterval
)timeInterval;
|
返回的值是通知视图。你可以忽略它。如果你需要进一步自定义的话,请继续看下去。
让通知消失
1
2
|
+ (
void
)dismiss;
+ (
void
)dismissAfter:(
NSTimeInterval
)delay;
|
显示进度
+ (void)showProgress:(CGFloat)progress;
显示活动
1
2
|
+ (
void
)showActivityIndicator:(
BOOL
)show
indicatorStyle:(UIActivityIndicatorViewStyle)style;
|
选择不同风格的通知
可选的风格有:JDStatusBarStyleDefault, JDStatusBarStyleDark, JDStatusBarStyleError, JDStatusBarStyleWarning以及 JDStatusBarStyleSuccess。
1
2
3
4
5
6
|
+ (UIView*)showWithStatus:(
NSString
*)status
styleName:(
NSString
*)styleName;
+ (UIView*)showWithStatus:(
NSString
*)status
dismissAfter:(
NSTimeInterval
)timeInterval
styleName:(
NSString
*)styleName;
|
使用这些定制的风格,你可以使用identifier,在addStyleNamed:prepare:中指定即可。见下面的定制化。
定制化
1
2
3
4
|
+ (
void
)setDefaultStyle:(JDPrepareStyleBlock)prepareBlock;
+ (
NSString
*)addStyleNamed:(
NSString
*)identifier
prepare:(JDPrepareStyleBlock)prepareBlock;
|
prepareBlock提供了默认风格,你可以按照以下修改:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[JDStatusBarNotification addStyleNamed:<#identifier#>
prepare:^JDStatusBarStyle*(JDStatusBarStyle *style) {
style.barColor = <#color#>;
style.textColor = <#color#>;
style.font = <#font#>;
style.textShadow = <#shadow#>;
style.animationType = <#type#>;
style.progressBarColor = <#color#>;
style.progressBarHeight = <#height#>;
return
style;
}];
|
JDStatusBarNotification-master.zip (154 K) 下载次数:135