• Stars
    star
    188
  • Rank 205,563 (Top 5 %)
  • Language
    Objective-C
  • Created almost 13 years ago
  • Updated almost 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lightweight notifications in iOS apps

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:

// Assume your view controller has an SJNotificationViewController* ivar called _notificationController.
_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.

More Repositories

1

SJGeocoder

A drop-in CLGeocoder replacement that adds MKLocalSearch results to geocode queries
Objective-C
56
star
2

hu

Hu watches you and takes notes.
Python
34
star
3

hn-api

A simple, ad-hoc Python API for Hacker News
Python
25
star
4

mobile-dl

mobile-dl is a roll-your-own Instapaper for rich media.
Python
23
star
5

hnsh

hnsh is a way of reading Hacker News from the command-line
Python
16
star
6

SJInstagramEngine

A Cocoa wrapper around the Instagram API
Objective-C
14
star
7

Throttle

A small Mac OS X app that throttles your bandwidth
Shell
7
star
8

GLSReadingList

An Objective-C API to the user's Reading List on OS X
Objective-C
4
star
9

Shortcuts

Shortcuts are an easy way to quickly view all of your web browser's keyboard shortcuts without interrupting what you're doing.
JavaScript
3
star
10

TumblrHTML5Audio

Lets you listen to audio posts on your Tumblr Dashboard without Flash.
JavaScript
3
star
11

mdWidget

mdWidget is a Mac OS X Dashboard Widget that gives you quick access to a reference for Markdown's (http://daringfireball.net/projects/markdown/) syntax.
JavaScript
2
star
12

Secret-Sharing

This is part of a cryptography paper I'm writing on using the principles of secret-sharing to manage secure passwords.
Python
2
star
13

instahn

instahn is a Python script that adds every story on the front page of Hacker News to your Instapaper.
Python
2
star
14

TwitterFreq

TwitterFreq graphs a Twitter user's tweets based on when during the day/week they were published.
Python
2
star
15

Tumblr-Theme

I decided to put the theme for my Tumblr (http://words.scottjackson.org) under version control so that next time I mess it up, I can put it back to normal.
2
star
16

Trackr-Extensions

Browser extensions related to Trackr, a thing I'm working on for my research project.
JavaScript
1
star
17

NTYouTube

NTYouTube is a kind of URL forwarding service for a popular video site.
PHP
1
star
18

test

test
1
star
19

FooCam

Python
1
star
20

YouTube-center

A Safari extension that centers a YouTube video on its page.
1
star
21

Trackr

A small part of my thesis project. Trackr watches what you like online.
Python
1
star
22

Modulo

Addressing the missing modulo function in the iPhone's built-in Calculator since 2010.
1
star
23

scottjacksonx.github.com

My github page.
1
star
24

KeySearch

A hack-y Safari 5.2 replacement for SafariKeywordSearch
JavaScript
1
star
25

phenny

My phenny modules
Python
1
star
26

Mac-N--Tosh

A Tumblr theme I made that takes visual cues from a 68k Macintosh.
1
star
27

--

A distraction-free writing environment
Objective-C
1
star
28

twitter-crushes

Tells you who love on Twitter. But not in a weird way.
Python
1
star
29

SJMapView

An MKMapView subclass that detects status bar taps (and by default, scrolls to the user's location)
Objective-C
1
star
30

Movies

Movies is a little web app for keeping track of which movies you'd like to watch.
JavaScript
1
star