Permalink
Browse files

Added text and colour additions

  • Loading branch information...
1 parent f27ec20 commit 8720de15b402ba87017cca1f010953d738d76725 @doronkatz doronkatz committed Sep 6, 2011
View
@@ -26,7 +26,7 @@ typedef enum {
@end
@interface JSScrollableTabBar : UIView <UIScrollViewDelegate> {
-
+
UIScrollView *_scrollView;
NSMutableArray *_tabItems;
@@ -47,6 +47,5 @@ typedef enum {
- (id)initWithFrame:(CGRect)frame style:(JSScrollableTabBarStyle)style;
- (void)setTabItems:(NSArray *)tabItems;
-- (void)selectTabAtIndex:(NSInteger)index;
@end
View
@@ -14,6 +14,7 @@ @interface JSScrollableTabBar ()
- (void)layoutTabs;
- (void)updateFaders;
- (void)tabSelected:(id)sender;
+- (void)selectTabAtIndex:(NSInteger)index;
@end
@@ -29,11 +30,11 @@ - (id)initWithFrame:(CGRect)frame style:(JSScrollableTabBarStyle)style
{
_tabItems = [[NSMutableArray alloc] init];
- _background = [[UIImageView alloc] initWithFrame:self.bounds];
+ _background = [[UIImageView alloc] initWithFrame:frame];
[_background setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[self addSubview:_background];
- _scrollView = [[UIScrollView alloc] initWithFrame:self.bounds];
+ _scrollView = [[UIScrollView alloc] initWithFrame:frame];
[_scrollView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[_scrollView setShowsHorizontalScrollIndicator:NO];
[_scrollView setShowsVerticalScrollIndicator:NO];
@@ -129,7 +130,7 @@ - (void)layoutTabs
for (JSTabItem *item in _tabItems)
{
- JSTabButton *tabButton = [JSTabButton tabButtonWithTitle:[item title]];
+ JSTabButton *tabButton = [JSTabButton tabButtonWithTitle:[item title] andColor:[item color] andTextColor:[item textColor]];
[tabButton setTag:[_tabItems indexOfObject:item]];
[tabButton addTarget:self
action:@selector(tabSelected:)
@@ -146,7 +147,7 @@ - (void)layoutTabs
[_scrollView addSubview:tabButton];
}
-
+
[_scrollView setContentSize:CGSizeMake((overallWidth + padding), self.frame.size.height)];
[self selectTabAtIndex:0];
[self updateFaders];
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "D2AAC07D0554694100DB518D"
+ BuildableName = "libJSScrollableTabBar.a"
+ BlueprintName = "JSScrollableTabBar"
+ ReferencedContainer = "container:JSScrollableTabBar.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ buildConfiguration = "Debug">
+ <Testables>
+ </Testables>
+ </TestAction>
+ <LaunchAction
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Debug"
+ debugDocumentVersioning = "YES"
+ allowLocationSimulation = "YES">
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ buildConfiguration = "Release"
+ debugDocumentVersioning = "YES">
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>SchemeUserState</key>
+ <dict>
+ <key>JSScrollableTabBar.xcscheme</key>
+ <dict>
+ <key>orderHint</key>
+ <integer>17</integer>
+ </dict>
+ </dict>
+ <key>SuppressBuildableAutocreation</key>
+ <dict>
+ <key>D2AAC07D0554694100DB518D</key>
+ <dict>
+ <key>primary</key>
+ <true/>
+ </dict>
+ </dict>
+</dict>
+</plist>
View
@@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>
@interface JSTabButton : UIButton {
-
+
BOOL _toggled;
UIImage *_normalBg;
@@ -20,6 +20,6 @@
@property (nonatomic, retain) UIImage *normalBg;
@property (nonatomic, retain) UIImage *highlightedBg;
-+ (JSTabButton *)tabButtonWithTitle:(NSString *)string;
++ (JSTabButton *)tabButtonWithTitle:(NSString *)string andColor:(UIColor*)color andTextColor:(UIColor*)textColor;
@end
View
@@ -14,11 +14,11 @@ @implementation JSTabButton
@synthesize normalBg = _normalBg;
@synthesize highlightedBg = _highlightedBg;
-+ (JSTabButton *)tabButtonWithTitle:(NSString *)string
++ (JSTabButton *)tabButtonWithTitle:(NSString *)string andColor:(UIColor*)color andTextColor:(UIColor*)textColor
{
NSString *imageBundlePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"images.bundle"];
NSBundle *imageBundle = [NSBundle bundleWithPath:imageBundlePath];
-
+
static UIImage *normalButton = nil;
static UIImage *highlightedButton = nil;
@@ -35,15 +35,17 @@ + (JSTabButton *)tabButtonWithTitle:(NSString *)string
}
JSTabButton *button = (JSTabButton *)[self buttonWithType:UIButtonTypeCustom];
- [button setNormalBg:normalButton];
- [button setHighlightedBg:highlightedButton];
+
[button setAdjustsImageWhenHighlighted:NO];
- [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
+ [button setTitleColor:textColor forState:UIControlStateNormal];
+ [button setTitleColor:textColor forState:UIControlStateApplication];
+ [button setTitleColor:textColor forState:UIControlStateHighlighted];
+
+ [button setBackgroundColor:color];
[[button titleLabel] setFont:[UIFont fontWithName:@"Helvetica-Bold" size:14]];
[button setTitleShadowColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [[button titleLabel] setShadowOffset:CGSizeMake(0.0, 0.5)];
+
[[button titleLabel] setLineBreakMode:UILineBreakModeTailTruncation];
- [button setTitleEdgeInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
[button setTitle:string forState:UIControlStateNormal];
View
@@ -7,16 +7,21 @@
//
#import <Foundation/Foundation.h>
-
+#import <UIKit/uikit.h>
@interface JSTabItem : NSObject {
-
+
NSString *_title;
+ UIColor *_textColor;
+ UIColor *_color;
}
@property (nonatomic, copy) NSString *title;
+@property (nonatomic, copy) UIColor *color;
+@property (nonatomic, copy) UIColor *textColor;
+
-- (id)initWithTitle:(NSString *)title;
+- (id)initWithTitle:(NSString *)title andColor:(UIColor*)color andTextColor:(UIColor*)textColor;
@end
View
@@ -7,17 +7,21 @@
//
#import "JSTabItem.h"
-
+#import <UIKit/uikit.h>
@implementation JSTabItem
@synthesize title = _title;
+@synthesize color = _color;
+@synthesize textColor = _textColor;
-- (id)initWithTitle:(NSString *)title
+- (id)initWithTitle:(NSString *)title andColor:(UIColor*)color andTextColor:(UIColor *)textColor;
{
if ((self = [super init]))
{
self.title = title;
+ self.textColor = textColor;
+ self.color = color;
}
return self;
@@ -26,6 +30,8 @@ - (id)initWithTitle:(NSString *)title
- (void)dealloc
{
self.title = nil;
+ self.textColor = nil;
+ self.color = nil;
[super dealloc];
}

0 comments on commit 8720de1

Please sign in to comment.