[IOS 消息提醒]--网络或操作的成功失败提醒AJNotificationView


https://github.com/ajerez/AJNotificationView

AJNotificationView

Notice component for iOS

  • No images needed, all CoreGraphics code
  • Works on iPhone and iPad (resolution independent)
  • Animated background type
  • Only one notification is shown at a time. When a notification is created, it is added to the queue. If it is the only notification in the queue, then its delay interval is honored. If it is not the only notification in the queue, it is placed at the end of the queue, and then displayed without a delay once it reaches the front of the queue (Thanks to @DazeEnd).

Video demo

AJNotificationView

AJNotificationView

Example Usage

Add QuartzCore.framework and drop the AJNotificationView folder in your project

//Blue notification with animated lined background. Hides after 2,5 seg
[AJNotificationView showNoticeInView:self.view
                                type:AJNotificationTypeBlue
                               title:@"Test notification"
                     linedBackground:AJLinedBackgroundTypeAnimated
                           hideAfter:2.5f];
// Orange notification without lined background. Remains visible until the user taps in it, or you call hide method
AJNotificationView *panel = [AJNotificationView showNoticeInView:self.view
                                type:AJNotificationTypeOrange
                               title:@"Test notification"
                     linedBackground:AJLinedBackgroundTypeDisabled
                           hideAfter:0];
//Your code
[panel hide];
// Notification with delay, offset and response block that's called when the user tap in it.
//Thanks to @DazeEnd for this awesome features
[AJNotificationView showNoticeInView:self.view
                                    type:AJNotificationTypeBlue
                                   title:@"Oppa Gangnam Style!"
                         linedBackground:AJLinedBackgroundTypeDisabled
                               hideAfter:2.5f
                                  offset:50.0f
                                   delay:1.0f
                                response:^{
                                    NSLog(@"User tap in the notification");
                                }
    ];
// Notification with delay, offset, response block and detail disclosure button that send a notification when the user tap in it
//Thanks to @smoothdvd for this last feature

//In viewDidLoad register the NSNotification
- (void)viewDidLoad{   
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(detailDisclosureButtonPressed:)
                                                 name:@"detail_disclosure_button_pressed"
                                               object:nil];
   [super viewDidLoad];
}

//...
//Function that's called when the NSNotification is fired
- (void)detailDisclosureButtonPressed:(NSNotification*)notification{
    NSLog(@"Detail disclosure button pressed");
}

//...
//The code for show the AJNotificationView

    [AJNotificationView showNoticeInView:self.view
                                    type:AJNotificationTypeBlue
                                   title:@"Detail disclosure notification"
                         linedBackground:AJLinedBackgroundTypeAnimated
                               hideAfter:2.5f
                                  offset:0.0f
                                   delay:0.0f
                        detailDisclosure:YES
                                response:^{
                                    NSLog(@"Response block");
                                }
     ];

There are several notification styles to choose from:

  • AJNotificationTypeDefault <-- Gray
  • AJNotificationTypeBlue
  • AJNotificationTypeRed
  • AJNotificationTypeGreen
  • AJNotificationTypeOrange

And background types:

  • AJLinedBackgroundTypeDisabled
  • AJLinedBackgroundTypeStatic <-- Default
  • AJLinedBackgroundTypeAnimated

Future improvements

  • Code rafactoring
  • More background colors (Notification styles)

Inspiration

Contact

Twitter: @alberto_jrz

License - MIT

Copyright (c) 2012 Alberto Jerez - CodeApps

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值