Code Monkey home page Code Monkey logo

rknotificationhub's Introduction

RKNotificationHub

A way to quickly add a notification icon to a UIView (iOS6 and up). Support

demo

Code:

  RKNotificationHub* hub = [[RKNotificationHub alloc]initWithView:yourView]; // sets the count to 0
  [hub increment]; // increments the count to 1, making the notification visible

Pod

    pod 'RKNotificationHub'

USAGE

increment

  [hub increment];
  -(void)increment;
  -(void)incrementBy:(int)amount;
  -(void)decrement;
  -(void)decrementBy:(int)amount;
  @property (nonatomic, assign) int count; //%%% set to a certain number

Combine Actions!

blink

  [hub increment];
  [hub pop];

CUSTOMIZE

blink

  //%%% COLOR
  [hub setCircleColor:[UIColor colorWithRed:0.98 green:0.66 blue:0.2 alpha:1]
           labelColor:[UIColor whiteColor]];

frame

  //%%% CIRCLE FRAME
  [hub setCircleAtFrame:CGRectMake(-10, -10, 30, 30)]; //frame relative to the view you set it to

  //%%% MOVE FRAME
  [hub moveCircleByX:-5 Y:5]; // moves the circle 5 pixels left and down from its current position

  //%%% CIRCLE SIZE
  [hub scaleCircleSizeBy:2]; // doubles the size of the circle, keeps the same center

blank

  //%%% BLANK BADGE
  [hub hideCount];
  /* shoutout to imkevinxu for this suggestion */

TROUBLESHOOTING

Notification isn't showing up!

  • If the hub value is < 1, the circle hides. Try calling [increment]
  • Make sure the view you set the hub to is visible (i.e. did you call [self.view addSubview: yourView]?)
  • Make sure you didn't call [hideCount] anywhere. Call [showCount] to counter this

It isn't incrementing / decrementing properly!

  • I've written it so that any count < 1 doesn't show up. If you need help customizing this, reach out to me

The circle is in a weird place

  • If you want to resize the circle, use [scaleCircleSizeBy:]. 0.5 will give you half the size, 2 will give you double
  • If the circle is just a few pixels off, use [moveCircleByX: Y:]. This shifts the circle by the number of pixels given
  • If you want to manually set the circle, call [setCircleAtFrame:] and give it your own CGRect

Something else isn't working properly

  • Send me a tweet @cwRichardKim with #RKNotificationHub so that other people can search these issues too
  • Use github's issue reporter on the right
  • Send me an email [email protected] (might take a few days)

Updates

  • 1.0.0 first release with cocoapod
  • 1.0.1 cocoapod allows iOS 7.0
  • 1.0.2 added "hideCount", "showCount", and "count" methods, allowing indeterminate badges with no number
  • 1.0.5 added bubble expansion for larger numbers (gif)
  • 2.0.0 changed count to NSUInteger (removed support for negative counts), made local constants static const
  • 2.0.1 iOS 6 compatability
  • 2.0.2 changed count back to 'int' for better swift compatability
  • 2.0.4 fixed cocoapod update issue

Areas for Improvements / involvement

  • A mechanism for adding a custom animation
  • Singleton option

rknotificationhub's People

Contributors

cwrichardkim avatar filwag avatar vokal-isaac avatar steilerdev avatar esqarrouth avatar sohailkh avatar suriyaakudoisc avatar chillpop avatar tunam3lt avatar petaren avatar bryant1410 avatar redcapua 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.