Created
July 17, 2015 06:49
-
-
Save Quotation/31c68d9a46c1de6f9bf5 to your computer and use it in GitHub Desktop.
UITabBar height hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface CTResizeableTabBar : UITabBar | |
// tabbar高度,为0表示采用系统默认高度 | |
- (instancetype)initWithHeight:(CGFloat)tabBarHeight; | |
@end | |
@interface CTResizeableTabBar () | |
{ | |
@private | |
CGFloat _tabBarHeight; | |
} | |
@end | |
@implementation CTResizeableTabBar | |
- (instancetype)initWithHeight:(CGFloat)tabBarHeight | |
{ | |
self = [super init]; | |
if (self) { | |
_tabBarHeight = tabBarHeight; | |
} | |
return self; | |
} | |
- (CGSize)sizeThatFits:(CGSize)size | |
{ | |
CGSize sizeThatFits = [super sizeThatFits:size]; | |
if (_tabBarHeight > 0.0f) { | |
sizeThatFits.height = _tabBarHeight; | |
} | |
return sizeThatFits; | |
} | |
@end | |
@interface CTResizeableTabBarController : UITabBarController | |
// tabbar高度,为0表示采用系统默认高度 | |
- (instancetype)initWithHeight:(CGFloat)tabBarHeight; | |
@end | |
@interface CTResizeableTabBarController () | |
@property (nonatomic, readwrite) UITabBar *tabBar; | |
@end | |
@implementation CTResizeableTabBarController | |
- (instancetype)initWithHeight:(CGFloat)tabBarHeight; | |
{ | |
self = [super init]; | |
if (self) { | |
self.tabBar = [[CTResizeableTabBar alloc] initWithHeight:tabBarHeight]; | |
} | |
return self; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment