Code Monkey home page Code Monkey logo

afdropdownnotification's Introduction

AFDropdownNotification

Dropdown notification view for iOS

alt text

##Installation

If you're using CocoaPods, just add this line to your Podfile:

pod 'AFDropdownNotification', '~> 1.0'

If you're not, import these files to your project:

AFDropdownNotification.h
AFDropdownNotification.m

##Usage

First of all, init your AFDropdownNotification class and set your main class as AFDropdownNotificationDelegate:

AFDropdownNotification *notification = [[AFDropdownNotification alloc] init];
notification.notificationDelegate = self;

You can configure the title text with the titleText property, the subtitle text with subtitleText, an optional left image defined as image, and two optional buttons, with topButtonText and bottomButtonText. For example:

notification.titleText = @"Update available";
notification.subtitleText = @"Do you want to download the update of this file?";
notification.image = [UIImage imageNamed:@"update"];
notification.topButtonText = @"Accept";
notification.bottomButtonText = @"Cancel";

If you want to hide the notification by tapping it, set dimissOnTap to YES:

notification.dismissOnTap = YES;

To present it, you can choose if you want to use UIKit dynamics (which will include a subtle bounce) or a regular lineal UIKit animation:

[notification presentInView:self.view withGravityAnimation:YES];

Finally, to handle the buttons taps, implement the two methods defined by the delegate, -dropdownNotificationTopButtonTapped and -dropdownNotificationBottomButtonTapped.

-(void)dropdownNotificationTopButtonTapped {
 
    NSLog(@"Top button tapped");
}

-(void)dropdownNotificationBottomButtonTapped {

    NSLog(@"Bottom button tapped");
}

Also, you can use blocks:

[_notification listenEventsWithBlock:^(AFDropdownNotificationEvent event) {
       
    switch (event) {
        case AFDropdownNotificationEventTopButton:
            // Top button
            break;
                
        case AFDropdownNotificationEventBottomButton:
            // Bottom button
            break;
                
        case AFDropdownNotificationEventTap:
            // Tap
            break;
                
        default:
            break;
    }
}];

##TODO

  • Light theme
  • Autolayout support for rotation

##License AFDropdownNotification is under MIT license so feel free to use it!

##Author Made by Alvaro Franco. If you have any question, feel free to drop me a line at [email protected]

afdropdownnotification's People

Contributors

alvarofranco avatar havocked avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.