Git Product home page Git Product logo

sjnotificationviewcontroller's Introduction

SJNotificationViewController

SJNotificationViewController lets you put dead-simple notifications that slide up from the bottom or down from the top of a view into your iOS apps.

All you need to do is create a notification, give it a view to slide up from, and tell it to show itself. Like this:

SJNotificationViewController *notificationController = [[SJNotificationViewController alloc] initWithNibName:@"SJNotificationViewController" bundle:nil];
[notificationController setParentView:aView];
[notificationController setNotificationTitle:@"Hello"];
[notificationController show];

That gives you a basic notification that slides up from the bottom of aView. When you want your notification to slide back down, you just call [notificationController hide]. Pretty simple, right?

You can customise a few things about SJNotificationViewController:

Notification Levels

SJNotificationViewController has a property called notificationLevel that changes the notification's background colour. A notification's notificationLevel is one of SJNotificationLevelError (red -- for error notifications), SJNotificationLevelMessage (blue -- for regular notifications), or SJNotificationLevelSuccess (green -- for success notifications). The exact RGB values for the notification levels aren't set in stone yet. Right now, they're extremely red, extremely blue, and extremely green.

Notification Position

There is also a property called notificationPosition to control whether your notification should appear at the top or at the bottom of its parent view. Set it to SJNotificationPositionTop or SJNotificationPositionBottom (default) accordingly.

[notificationController setNotificationPosition:SJNotificationPositionTop];

Tapping on a Notification

By default, tapping on a notification just hides it, but you can define your own target/selector pair to be called when the notification is tapped with [notificationController setTapTarget:self action:@selector(doSomething)].

Showing notification for x seconds

Calling the showFor method will show the notification for a number of seconds.

[notificationController showFor:2];

Spinner

By default, a notification doesn't have a spinner, but you can give it one by calling [notificationController setShowSpinner:YES]. Doing so will shrink the notification's label to fit the spinner.

More In-Depth Customisations

If you want to get into the .m file, you can change the colours that correspond to the different notification levels, the durations of the various animations, and the opacity of the notification's background.

sjnotificationviewcontroller's People

Contributors

arnekolja avatar scottjacksonx 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.