Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# osx noise
.DS_Store
._*

# xcode noise
build/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#import <UIKit/UIKit.h>


@interface FirstViewController : UIViewController {

}
@interface FirstViewController : UIViewController

- (IBAction)runAction;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//

#import "FirstViewController.h"
#import "JBInfoBarManager.h"
#import "InfoBarAppDelegate.h"
#import "UITabBarController+JBInfoBar.h"

@implementation FirstViewController

Expand All @@ -20,8 +21,9 @@ - (void)viewDidLoad
*/

- (IBAction)runAction {
[[JBInfoBarManager sharedManager] showInfoBarWithMessage:@"Action from View 1"];
[NSTimer scheduledTimerWithTimeInterval:5.0 target:[JBInfoBarManager sharedManager] selector:@selector(hideInfoBar) userInfo:nil repeats:NO];
InfoBarAppDelegate *appDelegate = (InfoBarAppDelegate*) [[UIApplication sharedApplication] delegate];
[appDelegate.tabBarController showInfoBarWithMessage:@"Action from View 1"];
[NSTimer scheduledTimerWithTimeInterval:5.0 target:appDelegate.tabBarController selector:@selector(hideInfoBar) userInfo:nil repeats:NO];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
//

#import <UIKit/UIKit.h>

#import "JBInfoBar.h"

@interface InfoBarAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@interface InfoBarAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate>

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;

@end
20 changes: 6 additions & 14 deletions InfoBar/InfoBarAppDelegate.m → Code/Demo/InfoBarAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//

#import "InfoBarAppDelegate.h"
#import "JBInfoBarManager.h"
#import "UITabBarController+JBInfoBar.h"


@implementation InfoBarAppDelegate

Expand All @@ -16,29 +17,20 @@ @implementation InfoBarAppDelegate

@synthesize tabBarController=_tabBarController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the tab bar controller's current view as a subview of the window
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];

// Add the infoBar
[[JBInfoBarManager sharedManager] initInfoBarWithFrame:CGRectMake(0, self.tabBarController.tabBar.frame.origin.y,
self.tabBarController.tabBar.frame.size.width, 30)
backgroundColor:[UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.6f]
textColor:[UIColor whiteColor]
textFont:[UIFont systemFontOfSize:17.0f]];

[self.tabBarController.view insertSubview:[[JBInfoBarManager sharedManager] infoBar] belowSubview:self.tabBarController.tabBar];
[[JBInfoBarManager sharedManager] showInfoBarWithMessage:@"Test Up!"];
[self.tabBarController showInfoBarWithMessage:@"Test Up!"];

return YES;
}

- (void)hideInfoBar
{
[[JBInfoBarManager sharedManager] hideInfoBarWithMessage:@"Finished!"];
- (void)hideInfoBar {
[self.tabBarController hideInfoBarWithMessage:@"Finished!"];
}

- (void)applicationWillResignActive:(UIApplication *)application
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
//

#import "SecondViewController.h"
#import "JBInfoBarManager.h"
#import "InfoBarAppDelegate.h"
#import "UITabBarController+JBInfoBar.h"

@implementation SecondViewController

Expand All @@ -20,8 +21,9 @@ - (void)viewDidLoad
*/

- (IBAction)runAction {
[[JBInfoBarManager sharedManager] showInfoBarWithMessage:@"Action from View 2"];
[NSTimer scheduledTimerWithTimeInterval:5.0 target:[JBInfoBarManager sharedManager] selector:@selector(hideInfoBar) userInfo:nil repeats:NO];
InfoBarAppDelegate *appDelegate = (InfoBarAppDelegate*) [[UIApplication sharedApplication] delegate];
[appDelegate.tabBarController showInfoBarWithMessage:@"Action from View 2"];
[NSTimer scheduledTimerWithTimeInterval:5.0 target:appDelegate.tabBarController selector:@selector(hideInfoBar) userInfo:nil repeats:NO];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions Code/Library/InfoBarStaticLibrary-Prefix.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//
// Prefix header for all source files of the 'InfoBarStaticLibrary' target in the 'InfoBarStaticLibrary' project
//

#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
45 changes: 45 additions & 0 deletions Code/Library/JBInfoBar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// JBInfoBar.h
// InfoBar
//
// Created by Junior B. on 20.02.11.
// Copyright 2011 ThinkDiff.ch. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface JBInfoBar : UIView {
CGPoint hiddenCP;
CGPoint showCP;

@private
UILabel *infoLabel;
NSTimer *hideTimer;
}


- (id)initWithFrame:(CGRect)frame;

- (void)showWithMessage:(NSString *)message;
- (void)showWithMessage:(NSString *)message hideAfterDelay:(NSTimeInterval)delay;

- (void)hide;
- (void)hideWithMessage:(NSString *)message;
- (void)hideImmediately;


@property (nonatomic, copy) NSString *message;

@property (nonatomic, readonly, assign) BOOL visible;

@property (nonatomic, assign) NSTimeInterval hideAnimationDelay;
@property (nonatomic, assign) NSTimeInterval hideAnimationDuration;
@property (nonatomic, assign) NSTimeInterval showAnimationDuration;

@property (nonatomic, retain) UIColor *textColor;
@property (nonatomic, retain) UIFont *textFont;

@property (nonatomic, readonly) UILabel *infoLabel;

@end
201 changes: 201 additions & 0 deletions Code/Library/JBInfoBar.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
//
// JBInfoBar.m
// InfoBar
//
// Created by Junior B. on 20.02.11.
// Copyright 2011 ThinkDiff.ch. All rights reserved.
//

#import "JBInfoBar.h"

#define kDefaultFont [UIFont systemFontOfSize:17.0f]

#define kDefaultBackgroundColor [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.6f]
#define kDefaultTextColor [UIColor whiteColor]

#define kDefaultHideAnimationDelay 0.0f
#define kDefaultHideAnimationDuration 1.5f
#define kDefaultShowAnimationDuration 0.5f


@interface JBInfoBar ()

- (void) prepareCenterPoints;
- (void) prepareInfoLabel;
- (void) prepareDefaultTimings;

- (void) cancelAndClearHideTimer;

@end


@implementation JBInfoBar

@synthesize visible;
@synthesize hideAnimationDelay;
@synthesize hideAnimationDuration;
@synthesize showAnimationDuration;


#pragma Public Action Methods

- (void)showWithMessage:(NSString *)_message {
[self cancelAndClearHideTimer];

self.message = _message;

if(visible)
return;

[self setHidden:NO];
[UIView transitionWithView:self duration:showAnimationDuration
options:UIViewAnimationOptionTransitionNone
animations:^ {
self.center = showCP;
}
completion:nil];
visible = YES;
}

- (void)showWithMessage:(NSString *)message hideAfterDelay:(NSTimeInterval)delay {
[self showWithMessage:message];

hideTimer = [[NSTimer scheduledTimerWithTimeInterval:delay target:self selector:@selector(hide) userInfo:nil repeats:NO] retain];
}

- (void)hide {
[self cancelAndClearHideTimer];

if(!visible)
return;

[UIView animateWithDuration:hideAnimationDuration
delay:hideAnimationDelay
options:UIViewAnimationOptionTransitionNone
animations:^ {
self.center = hiddenCP;
}
completion:^(BOOL finished) {
[self setHidden:YES];
}];
visible = NO;
}

- (void)hideWithMessage:(NSString *)_message {
[self cancelAndClearHideTimer];

self.message = _message;

[self hide];
}

- (void)hideImmediately {
[self cancelAndClearHideTimer];

if(!visible)
return;

self.center = hiddenCP;
[self setHidden:YES];
visible = NO;
}

#pragma mark Utility Methods

- (void) cancelAndClearHideTimer {
[hideTimer invalidate];
[hideTimer release];
hideTimer = nil;
}

#pragma mark Property Accessors

- (void)setMessage:(NSString *)_message {
infoLabel.text = _message;
}

- (NSString*)message {
return infoLabel.text;
}

- (void) setTextColor:(UIColor *)textColor {
infoLabel.textColor = textColor;
}

- (UIColor*) textColor {
return infoLabel.textColor;
}

- (void) setTextFont:(UIFont *)textFont {
infoLabel.font = textFont;
}

- (UIFont*) textFont {
return infoLabel.font;
}

- (UILabel *)infoLabel {
return infoLabel;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/

#pragma mark Instance Lifecycle

- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
visible = NO;

[self prepareCenterPoints];
[self prepareInfoLabel];

self.backgroundColor = kDefaultBackgroundColor;
self.hidden = YES;

[self prepareDefaultTimings];
}
return self;
}

- (void) prepareCenterPoints {
double centerX = self.frame.origin.x + self.frame.size.width / 2.0;
double hiddenCenterY = self.frame.origin.y + self.frame.size.height / 2.0;
double shownCenterY = self.frame.origin.y - self.frame.size.height / 2.0;

hiddenCP = CGPointMake(centerX, hiddenCenterY);
showCP = CGPointMake(centerX, shownCenterY);
}

- (void) prepareInfoLabel {
infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];

infoLabel.textAlignment = UITextAlignmentCenter;
infoLabel.backgroundColor = [UIColor clearColor];

infoLabel.font = kDefaultFont;
infoLabel.textColor = kDefaultTextColor;

[self addSubview:infoLabel];
}

- (void) prepareDefaultTimings {
hideAnimationDelay = kDefaultHideAnimationDelay;
hideAnimationDuration = kDefaultHideAnimationDuration;
showAnimationDuration = kDefaultShowAnimationDuration;
}

- (void)dealloc {
[infoLabel release];

[super dealloc];
}

@end
18 changes: 18 additions & 0 deletions Code/Library/UIKit Additions/UITabBarController+JBInfoBar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// UITabBarController+JBInfoBar.h
// InfoBar
//
// Created by Graham Haworth on 4/16/12.
//

#import "JBInfoBar.h"
#import "UIViewController+JBInfoBar.h"

#import <UIKit/UIKit.h>


@interface UITabBarController (JBInfoBar)

- (JBInfoBar*) createDefaultInfoBarWithHeight:(NSInteger)height;

@end
Loading