iOS开发之CDiscreetNotificationView

来源:互联网 发布:单片机usb转串口 编辑:程序博客网 时间:2024/06/05 02:14

CDiscreetNotificationView 类库作用是: 在不阻止用户与设备应用程序交互情况下,作为一个通知视图来显示一个当前的状态。

GCDiscreetNotificationView 类库下载地址 https://github.com/gcamp/GCDiscreetNotificationView


在开源中国iOS客户端上,当无法获取网络时,



我们常用的通知可能是一个UIAlertView的警告,提示当前网络未连接,这样就强制用户必须做出选择,被强制的肯定会不爽。这是GCDiscreetNotificationView类库相比较的一个优点;



关于怎样使用GCDiscreetNotificationView第三方类库,在开源中国iOS客户端中,这个开发类库被封装在一个Tool类中(Helper文件夹下),


[cpp] view plaincopy
  1. + (void)ToastNotification:(NSString *)text andView:(UIView *)view andLoading:(BOOL)isLoading andIsBottom:(BOOL)isBottom  
  2. {  
  3.     GCDiscreetNotificationView *notificationView = [[GCDiscreetNotificationView alloc] initWithText:text showActivity:isLoading inPresentationMode:isBottom?GCDiscreetNotificationViewPresentationModeBottom:GCDiscreetNotificationViewPresentationModeTop inView:view];  
  4.     [notificationView show:YES];  
  5.     [notificationView hideAnimatedAfter:2.6];  
  6. }  

然后在MessageSystemView.m的reload方法中调用也就一行代码,当然其他类中也可以调用,只需#import "Tool.h"

[Tool  ToastNotification:@"错误网络无连接"   andView:self.view    andLoading:NO    andIsBottom:NO];


GCDiscreetNotificationView类库不仅可以在顶部显示,还可以在底部显示,只需修改andIsBottom:传入的BOOL型参数为YES,这样它就在底部显示了。andLoading接受BOOL型参数用于显示一个加载过程。


我将这个类库放到另一个工程中,仿照开源中国iOS客户端里的方法用Tool类进行封装,做的一个测试

  

底部显示

  

0 0