Permalink
Browse files

Added custom UI navigation style

  • Loading branch information...
1 parent 11d77b6 commit 470729493706e27bbf10b27d04d000f94d3caceb @devinross committed Nov 29, 2010
Showing with 815 additions and 62 deletions.
  1. BIN src/TapkuLibrary.bundle/Images/gui/ui back button hover.png
  2. BIN src/TapkuLibrary.bundle/Images/gui/ui back button hover@2x.png
  3. BIN src/TapkuLibrary.bundle/Images/gui/ui back button.png
  4. BIN src/TapkuLibrary.bundle/Images/gui/ui back button@2x.png
  5. BIN src/TapkuLibrary.bundle/Images/gui/ui done button.png
  6. BIN src/TapkuLibrary.bundle/Images/gui/ui done button@2x.png
  7. BIN src/TapkuLibrary.bundle/Images/gui/ui plain button hover.png
  8. BIN src/TapkuLibrary.bundle/Images/gui/ui plain button hover@2x.png
  9. BIN src/TapkuLibrary.bundle/Images/gui/ui plain button.png
  10. BIN src/TapkuLibrary.bundle/Images/gui/ui plain button@2x.png
  11. +40 −0 src/TapkuLibrary.xcodeproj/project.pbxproj
  12. +55 −0 src/TapkuLibrary/TKBarButtonItem.h
  13. +242 −0 src/TapkuLibrary/TKBarButtonItem.m
  14. +11 −7 src/TapkuLibrary/TKCalendarMonthView.m
  15. +2 −1 src/TapkuLibrary/TKTableViewController.h
  16. +43 −0 src/TapkuLibrary/TKViewController.h
  17. +45 −0 src/TapkuLibrary/TKViewController.m
  18. +5 −0 src/TapkuLibrary/TapkuLibrary.h
  19. +40 −0 src/TapkuLibrary/UINavigationBar+TKCategory.h
  20. +69 −0 src/TapkuLibrary/UINavigationBar+TKCategory.m
  21. +40 −0 src/TapkuLibrary/UINavigationController+TKCategory.h
  22. +52 −0 src/TapkuLibrary/UINavigationController+TKCategory.m
  23. +39 −0 src/TapkuLibrary/UIToolbar+TKCategory.h
  24. +52 −0 src/TapkuLibrary/UIToolbar+TKCategory.m
  25. BIN universaldemo/Shared/Images/Back.png
  26. BIN universaldemo/Shared/Images/Back@2x.png
  27. +22 −0 universaldemo/Shared/main.m
  28. +3 −1 universaldemo/iPhone/AlertsViewController.m
  29. +1 −2 universaldemo/iPhone/DemoCalendarMonth.m
  30. +7 −11 universaldemo/iPhone/EmptyViewController.m
  31. +1 −1 universaldemo/iPhone/FastTableViewController.m
  32. +11 −9 universaldemo/iPhone/HUDViewController.m
  33. +3 −8 universaldemo/iPhone/LabelViewController.m
  34. +1 −0 universaldemo/iPhone/MapViewController.h
  35. +5 −10 universaldemo/iPhone/MapViewController.m
  36. +2 −1 universaldemo/iPhone/RootViewController.h
  37. +11 −6 universaldemo/iPhone/RootViewController.m
  38. +13 −5 universaldemo/universaldemo.xcodeproj/project.pbxproj
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -9,6 +9,16 @@
/* Begin PBXBuildFile section */
3B1DCECA1289B84400884CDF /* NSArray+TKCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B1DCEC81289B84400884CDF /* NSArray+TKCategory.h */; };
3B1DCECB1289B84400884CDF /* NSArray+TKCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B1DCEC91289B84400884CDF /* NSArray+TKCategory.m */; };
+ 3B30B174129EE0F400466666 /* TKViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B30B165129EE0D600466666 /* TKViewController.m */; };
+ 3B30B175129EE0F400466666 /* UINavigationController+TKCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B30B169129EE0DF00466666 /* UINavigationController+TKCategory.m */; };
+ 3B30B176129EE0F400466666 /* UINavigationBar+TKCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B30B16B129EE0DF00466666 /* UINavigationBar+TKCategory.m */; };
+ 3B30B177129EE0F400466666 /* UIToolbar+TKCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B30B16D129EE0DF00466666 /* UIToolbar+TKCategory.m */; };
+ 3B30B178129EE10B00466666 /* TKViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B30B164129EE0D600466666 /* TKViewController.h */; };
+ 3B30B179129EE10B00466666 /* UINavigationController+TKCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B30B168129EE0DF00466666 /* UINavigationController+TKCategory.h */; };
+ 3B30B17A129EE10B00466666 /* UINavigationBar+TKCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B30B16A129EE0DF00466666 /* UINavigationBar+TKCategory.h */; };
+ 3B30B17B129EE10B00466666 /* UIToolbar+TKCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B30B16C129EE0DF00466666 /* UIToolbar+TKCategory.h */; };
+ 3B30B192129EE17500466666 /* TKBarButtonItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B30B190129EE17500466666 /* TKBarButtonItem.h */; };
+ 3B30B193129EE17500466666 /* TKBarButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B30B191129EE17500466666 /* TKBarButtonItem.m */; };
3B6EDDD311547BEB00E454DA /* TapkuLibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = 3BAC9A1B10953E5200F235F1 /* TapkuLibrary.h */; };
3B6EDDD611547BF800E454DA /* TKGlobal.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BAC9A1E10953E5200F235F1 /* TKGlobal.m */; };
3B6EDDDA11547C1100E454DA /* UIView+TKCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BAC9A2210953E5200F235F1 /* UIView+TKCategory.m */; };
@@ -105,6 +115,16 @@
/* Begin PBXFileReference section */
3B1DCEC81289B84400884CDF /* NSArray+TKCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+TKCategory.h"; sourceTree = "<group>"; };
3B1DCEC91289B84400884CDF /* NSArray+TKCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+TKCategory.m"; sourceTree = "<group>"; };
+ 3B30B164129EE0D600466666 /* TKViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKViewController.h; sourceTree = "<group>"; };
+ 3B30B165129EE0D600466666 /* TKViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKViewController.m; sourceTree = "<group>"; };
+ 3B30B168129EE0DF00466666 /* UINavigationController+TKCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationController+TKCategory.h"; sourceTree = "<group>"; };
+ 3B30B169129EE0DF00466666 /* UINavigationController+TKCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+TKCategory.m"; sourceTree = "<group>"; };
+ 3B30B16A129EE0DF00466666 /* UINavigationBar+TKCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UINavigationBar+TKCategory.h"; sourceTree = "<group>"; };
+ 3B30B16B129EE0DF00466666 /* UINavigationBar+TKCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UINavigationBar+TKCategory.m"; sourceTree = "<group>"; };
+ 3B30B16C129EE0DF00466666 /* UIToolbar+TKCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIToolbar+TKCategory.h"; sourceTree = "<group>"; };
+ 3B30B16D129EE0DF00466666 /* UIToolbar+TKCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIToolbar+TKCategory.m"; sourceTree = "<group>"; };
+ 3B30B190129EE17500466666 /* TKBarButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKBarButtonItem.h; sourceTree = "<group>"; };
+ 3B30B191129EE17500466666 /* TKBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKBarButtonItem.m; sourceTree = "<group>"; };
3B3991EE10CED8FD00B8FF4F /* TKGraphView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKGraphView.h; sourceTree = "<group>"; };
3B3991EF10CED8FD00B8FF4F /* TKGraphView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKGraphView.m; sourceTree = "<group>"; };
3B6EDD521154791900E454DA /* libTapkuLibraryExtra.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libTapkuLibraryExtra.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -431,6 +451,12 @@
3BAC9A2010953E5200F235F1 /* UIImage+TKCategory.m */,
3BE8FF8312945C4400DBF3FC /* UIScrollview+TKCategory.h */,
3BE8FF8412945C4400DBF3FC /* UIScrollview+TKCategory.m */,
+ 3B30B168129EE0DF00466666 /* UINavigationController+TKCategory.h */,
+ 3B30B169129EE0DF00466666 /* UINavigationController+TKCategory.m */,
+ 3B30B16A129EE0DF00466666 /* UINavigationBar+TKCategory.h */,
+ 3B30B16B129EE0DF00466666 /* UINavigationBar+TKCategory.m */,
+ 3B30B16C129EE0DF00466666 /* UIToolbar+TKCategory.h */,
+ 3B30B16D129EE0DF00466666 /* UIToolbar+TKCategory.m */,
);
name = Additions;
sourceTree = "<group>";
@@ -526,8 +552,12 @@
3BAC9A1D10953E5200F235F1 /* TKGlobal.h */,
3BAC9A1E10953E5200F235F1 /* TKGlobal.m */,
3BB3A1D1117814BC00553093 /* Additions */,
+ 3B30B164129EE0D600466666 /* TKViewController.h */,
+ 3B30B165129EE0D600466666 /* TKViewController.m */,
3BBF87491296E976008AB2B1 /* TKTableViewController.h */,
3BBF874A1296E976008AB2B1 /* TKTableViewController.m */,
+ 3B30B190129EE17500466666 /* TKBarButtonItem.h */,
+ 3B30B191129EE17500466666 /* TKBarButtonItem.m */,
3BEAE08E1096C61A00A0A372 /* TKWindow.h */,
3BEAE08F1096C61A00A0A372 /* TKWindow.m */,
);
@@ -617,6 +647,11 @@
3B1DCECA1289B84400884CDF /* NSArray+TKCategory.h in Headers */,
3BE8FF8512945C4400DBF3FC /* UIScrollview+TKCategory.h in Headers */,
3BBF874B1296E976008AB2B1 /* TKTableViewController.h in Headers */,
+ 3B30B178129EE10B00466666 /* TKViewController.h in Headers */,
+ 3B30B179129EE10B00466666 /* UINavigationController+TKCategory.h in Headers */,
+ 3B30B17A129EE10B00466666 /* UINavigationBar+TKCategory.h in Headers */,
+ 3B30B17B129EE10B00466666 /* UIToolbar+TKCategory.h in Headers */,
+ 3B30B192129EE17500466666 /* TKBarButtonItem.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -735,6 +770,11 @@
3B1DCECB1289B84400884CDF /* NSArray+TKCategory.m in Sources */,
3BE8FF8612945C4400DBF3FC /* UIScrollview+TKCategory.m in Sources */,
3BBF874C1296E976008AB2B1 /* TKTableViewController.m in Sources */,
+ 3B30B174129EE0F400466666 /* TKViewController.m in Sources */,
+ 3B30B175129EE0F400466666 /* UINavigationController+TKCategory.m in Sources */,
+ 3B30B176129EE0F400466666 /* UINavigationBar+TKCategory.m in Sources */,
+ 3B30B177129EE0F400466666 /* UIToolbar+TKCategory.m in Sources */,
+ 3B30B193129EE17500466666 /* TKBarButtonItem.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -0,0 +1,55 @@
+//
+// TKBarButtonItem.h
+// Created by Devin Ross on 11/24/10.
+//
+/*
+
+ tapku.com || http://github.com/devinross/tapkulibrary
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+ */
+
+#import <Foundation/Foundation.h>
+
+typedef enum {
+ TKBarButtonItemStylePlain,
+ TKBarButtonItemStyleBack,
+ TKBarButtonItemStyleDone
+} TKBarButtonItemStyle;
+
+
+@interface TKBarButtonItem : UIBarButtonItem {
+
+ UIButton *_buttonContainer;
+ TKBarButtonItemStyle _style;
+
+}
+
+- (id) initWithTitle:(NSString*)title style:(TKBarButtonItemStyle)style target:(id)target action:(SEL)action;
+- (id) initWithImage:(UIImage*)image style:(TKBarButtonItemStyle)style target:(id)target action:(SEL)action;
+
+- (TKBarButtonItemStyle) style;
+- (void) setStyle:(TKBarButtonItemStyle)s;
+- (void) setTarget:(id)target action:(SEL)action;
+
+@end
@@ -0,0 +1,242 @@
+//
+// TKBarButtonItem.m
+// Created by Devin Ross on 11/24/10.
+//
+/*
+
+ tapku.com || http://github.com/devinross/tapkulibrary
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+ */
+
+#import "TKBarButtonItem.h"
+#import "TKGlobal.h"
+#import "UIImage+TKCategory.h"
+
+@implementation TKBarButtonItem
+
+- (UIImage*) imageForStyle:(TKBarButtonItemStyle)s{
+ NSString *imageName;
+ NSString *scale = [[UIScreen mainScreen] scale] > 1 ? @"@2x" : @"";
+
+
+
+ switch (s) {
+ case TKBarButtonItemStyleBack:
+ imageName = @"ui back button";
+ break;
+ case TKBarButtonItemStyleDone:
+ imageName = @"ui done button";
+ break;
+ default:
+ imageName = @"ui plain button";
+ break;
+ }
+
+ NSString *url = [NSString stringWithFormat:@"TapkuLibrary.bundle/Images/gui/%@%@.png",imageName,scale];
+
+ UIImage *img = [UIImage imageWithCGImage:[UIImage imageWithContentsOfFile:TKBUNDLE(url)].CGImage
+ scale:[[UIScreen mainScreen] scale] orientation:UIImageOrientationUp];
+
+
+ return [img stretchableImageWithLeftCapWidth:24 topCapHeight:0];
+}
+- (UIImage*) hoverImageForStyle:(TKBarButtonItemStyle)s{
+
+ NSString *imageName;
+ NSString *scale = [[UIScreen mainScreen] scale] > 1 ? @"@2x" : @"";
+
+
+ switch (s) {
+ case TKBarButtonItemStyleBack:
+ imageName = @"ui back button hover";
+ break;
+ default:
+ imageName = @"ui plain button hover";
+ break;
+ }
+
+ NSString *url = [NSString stringWithFormat:@"TapkuLibrary.bundle/Images/gui/%@%@.png",imageName,scale];
+
+ UIImage *img = [UIImage imageWithCGImage:[UIImage imageWithContentsOfFile:TKBUNDLE(url)].CGImage
+ scale:[[UIScreen mainScreen] scale] orientation:UIImageOrientationUp];
+
+
+ return [img stretchableImageWithLeftCapWidth:24 topCapHeight:0];
+}
+- (UIEdgeInsets) insetForStyle:(TKBarButtonItemStyle)s{
+
+ UIEdgeInsets e;
+
+ switch (s) {
+ case TKBarButtonItemStyleBack:
+ e = UIEdgeInsetsMake(0, 14, 2, 6);
+ break;
+ default:
+ e = UIEdgeInsetsMake(0, 8, 2, 8);
+ break;
+ }
+
+ return e;
+
+}
+- (UIEdgeInsets) insetForImageWithStyle:(TKBarButtonItemStyle)s{
+ UIEdgeInsets e;
+
+ switch (s) {
+ case TKBarButtonItemStyleBack:
+ e = UIEdgeInsetsMake(0, 12, 2, 8);
+ break;
+ default:
+ e = UIEdgeInsetsMake(0, 8, 2, 8);
+ break;
+ }
+
+ return e;
+
+}
+
+- (void) setupButtonWithStyle:(TKBarButtonItemStyle)s{
+
+
+ UIImage *glyph = [_buttonContainer imageForState:UIControlStateNormal];
+
+
+ if(!glyph){
+ UIEdgeInsets e = [self insetForStyle:s];
+ _buttonContainer.titleEdgeInsets = e;
+ NSString *ti = [_buttonContainer titleForState:UIControlStateNormal];
+ CGSize size = [ti sizeWithFont:_buttonContainer.titleLabel.font forWidth:200 lineBreakMode:UILineBreakModeTailTruncation];
+ _buttonContainer.frame = CGRectMake(_buttonContainer.frame.origin.x, _buttonContainer.frame.origin.y, size.width + e.left + e.right, 30);
+
+ }else{
+ UIEdgeInsets e = [self insetForImageWithStyle:s];
+ _buttonContainer.imageEdgeInsets = e;
+ _buttonContainer.frame = CGRectMake(_buttonContainer.frame.origin.x, _buttonContainer.frame.origin.y, glyph.size.width + e.left + e.right, 30);
+ }
+
+
+ [_buttonContainer setBackgroundImage:[self imageForStyle:s] forState:UIControlStateNormal];
+ [_buttonContainer setBackgroundImage:[self hoverImageForStyle:s] forState:UIControlStateHighlighted];
+ _buttonContainer.showsTouchWhenHighlighted = NO;
+ _buttonContainer.adjustsImageWhenHighlighted = NO;
+}
+
+
+- (id) initWithTitle:(NSString*)_title style:(TKBarButtonItemStyle)s target:(id)t action:(SEL)a{
+ if(!(self = [super initWithCustomView:nil])) return nil;
+
+ self.title = _title;
+
+
+ _buttonContainer = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
+ _buttonContainer.frame = CGRectMake(0, 0, 30, 30);
+
+
+ _buttonContainer.titleLabel.textColor = [UIColor whiteColor];
+ _buttonContainer.titleLabel.font = [UIFont boldSystemFontOfSize:13];
+ _buttonContainer.titleLabel.shadowColor = [UIColor blackColor];
+ _buttonContainer.titleLabel.shadowOffset = CGSizeMake(0, -1);
+ _buttonContainer.titleLabel.backgroundColor = [UIColor clearColor];
+ _buttonContainer.showsTouchWhenHighlighted = NO;
+ _buttonContainer.adjustsImageWhenHighlighted = NO;
+
+
+ [_buttonContainer setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+ [_buttonContainer setTitle:_title forState:UIControlStateNormal];
+ [_buttonContainer addTarget:t action:a forControlEvents:UIControlEventTouchUpInside];
+
+ [self setupButtonWithStyle:s];
+
+ self.customView = _buttonContainer;
+
+
+ _style = s;
+
+
+ return self;
+}
+- (id) initWithImage:(UIImage*)img style:(TKBarButtonItemStyle)s target:(id)t action:(SEL)a{
+
+ if(!(self = [super initWithCustomView:nil])) return nil;
+
+ _buttonContainer = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
+ _buttonContainer.frame = CGRectMake(0, 0, 30, 30);
+
+ [_buttonContainer setImage:img forState:UIControlStateNormal];
+ [_buttonContainer addTarget:t action:a forControlEvents:UIControlEventTouchUpInside];
+ [self setupButtonWithStyle:s];
+
+ self.customView = _buttonContainer;
+
+ _style = s;
+
+
+ return self;
+}
+
+- (void) setTarget:(id)target{
+ return;
+}
+- (void) setAction:(SEL)a{
+ return;
+}
+- (id) target{
+ NSSet *set = [_buttonContainer allTargets];
+ if([set count] < 1) return nil;
+ return [[_buttonContainer allTargets] anyObject];
+}
+- (SEL) action{
+ return NSSelectorFromString([[_buttonContainer actionsForTarget:[[_buttonContainer allTargets] anyObject] forControlEvent:UIControlEventTouchUpInside] lastObject]);
+}
+- (void) setTarget:(id)tt action:(SEL)aa{
+
+ id t = [self target];
+ if(t != nil){
+ SEL act = NSSelectorFromString([[_buttonContainer actionsForTarget:[[_buttonContainer allTargets] anyObject] forControlEvent:UIControlEventTouchUpInside] lastObject]);
+ [_buttonContainer removeTarget:t action:act forControlEvents:UIControlEventTouchUpInside];
+ }
+
+
+ [_buttonContainer addTarget:tt action:aa forControlEvents:UIControlEventTouchUpInside];
+}
+- (TKBarButtonItemStyle) style{
+ return _style;
+}
+- (void) setStyle:(TKBarButtonItemStyle)s{
+
+ _style = s;
+
+ [self setupButtonWithStyle:s];
+
+
+
+}
+
+
+- (void) dealloc{
+ [_buttonContainer release];
+ [super dealloc];
+}
+
+@end
Oops, something went wrong.

0 comments on commit 4707294

Please sign in to comment.