Skip to content

Instantly share code, notes, and snippets.

@Quotation
Created July 17, 2015 06:49
Show Gist options
  • Save Quotation/31c68d9a46c1de6f9bf5 to your computer and use it in GitHub Desktop.
Save Quotation/31c68d9a46c1de6f9bf5 to your computer and use it in GitHub Desktop.
UITabBar height hack
@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