EMNotificationPopup 0.3.0

EMNotificationPopup 0.3.0

测试已测试
Lang语言 Obj-CObjective C
许可证 自定义
发布上一次发布2016年3月

Ennio Masi维护。



ENotificationPopup

EMNotificationPopup 是一个可定制、易于使用且带有良好动画的通知弹出窗口。

  • 通用构建
  • 使用 ARC (自动引用计数)
  • 支持 iOS > 6.0
  • 可重用组件

如何安装?

源代码

或者您可以简单地复制文件夹 EMNotificationPopup 中包含的所有文件,然后开始玩弄它!

它如何工作?

EMNotificationPopup 类

@interface EMNotificationPopup : UIView

@property NSObject <EMNotificationPopupDelegate> *delegate;

@property (nonatomic, strong) NSString *actionTitle;
@property (nonatomic, strong) UIImage *image;
@property (nonatomic, strong) NSString *subtitle;
@property (nonatomic, strong) NSString *title;

// Init default View
- (id) initWithType: (EMNotificationPopupType) type enterDirection:(EMNotificationPopupDirection) enter exitDirection:(EMNotificationPopupDirection) exit popupPosition: (EMNotificationPopupPosition) position;

// Init custom view
- (id) initWithView:(UIView *)view enterDirection:(EMNotificationPopupDirection) enter exitDirection:(EMNotificationPopupDirection) exit popupPosition: (EMNotificationPopupPosition) position;

// Actions on the popup view
- (void) dismissWithAnimation:(BOOL) animate;
- (void) show;
- (BOOL) isVisible;

// (new in 0.2.2) Customize the bounce power
- (void) setBouncePower:(NSInteger) bouncePower;

// Customize the default view
- (void) setPopupActionBackgroundColor: (UIColor *) color;
- (void) setPopupActionTitleColor: (UIColor *) color;
- (void) setPopupBorderColor: (UIColor *)color;
- (void) setPopupBackgroundColor:(UIColor *)color;
- (void) setPopupSubtitleColor:(UIColor *)color;
- (void) setPopupTitleColor:(UIColor *)color;
@end

EMNotificationPopupDelegate 协议

@protocol EMNotificationPopupDelegate
- (void) emNotificationPopupActionClicked;
@end

如何使用?

示例 - 使用默认弹出视图

    EMNotificationPopup *notificationPopup = [[EMNotificationPopup alloc] initWithImage:[UIImage imageNamed:@"alert_image"] andTitle:@"Hi, this is an alert message!" andSubTitle:@"Sorry for this message :)" andButtonTitle:@"OK"];
    notificationPopup.delegate = self;
    [notificationPopup showWithEnterDirection:EMNotificationPopupToDown andExitDirection:EMNotificationPopupToLeft];

示例 - 使用默认视图

这是一个使用“大”通知弹出窗口的示例。这是一个很大的(比大还要高)通知,能够显示图像、标题和副标题。如果实例化 EMNotificationPopupBigButton,您可以自定义动作按钮标题和颜色。此按钮用于关闭视图。

    _notificationPopup = [[EMNotificationPopup alloc] initWithType:notificationPopupType enterDirection:EMNotificationPopupToDown exitDirection:EMNotificationPopupToLeft popupPosition:position];
    _notificationPopup.delegate = self;

    _notificationPopup.title = @"Sorry for this Alert message :)";
    _notificationPopup.subtitle = @"Awesome message :)";
    _notificationPopup.image = [UIImage imageNamed:@"alert_image"];

    if (notificationPopupType == EMNotificationPopupBigButton)
        _notificationPopup.actionTitle = @"OK";

    [_notificationPopup show];

这是一个使用“瘦”通知弹出窗口的示例。这是一个瘦长的矩形通知,只能显示标题。

    _notificationPopup = [[EMNotificationPopup alloc] initWithType:EMNotificationPopupSlim enterDirection:EMNotificationPopupToDown exitDirection:EMNotificationPopupToLeft popupPosition:position];
    _notificationPopup.delegate = self;

    _notificationPopup.title = @"Sorry for this Alert message :)";

    [_notificationPopup show];

可以通过以下方法轻松地使用以下方法对这两个视图进行自定义:

- (void) setPopupActionBackgroundColor: (UIColor *) color;
- (void) setPopupActionTitleColor: (UIColor *) color;
- (void) setPopupBorderColor: (UIColor *)color;
- (void) setPopupBackgroundColor:(UIColor *)color;
- (void) setPopupSubtitleColor:(UIColor *)color;
- (void) setPopupTitleColor:(UIColor *)color;

示例 - 使用自定义视图

    UIView *shownView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 250.0f, 125.0f)];
    shownView.backgroundColor = [UIColor redColor];

    UIButton *closeMe = [[UIButton alloc] initWithFrame:CGRectMake(shownView.frame.size.width - 25.0f, 3.0f, 22.0f, 22.0f)];
    closeMe.backgroundColor = [UIColor clearColor];
    [closeMe setBackgroundImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
    [closeMe addTarget:self action:@selector(dismissMe) forControlEvents:UIControlEventTouchDown];
    [shownView addSubview:closeMe];

    _notificationPopup = [[EMNotificationPopup alloc] initWithView:shownView enterDirection:EMNotificationPopupToRight exitDirection:EMNotificationPopupToRight popupPosition:position];
    _notificationPopup.delegate = self;

    [_notificationPopup show];

使用 EMNotificationPopup 的应用程序

Twists&Turns

My Soldier for Battlefield 4 Smartcomix

帮助我改进这个!

如何做?简单地免费分支该项目并改进它!

如果您想联系我:Twitter: ennioma. 电子邮件: [email protected]