iOS navigationbar的高度可以修改吗
1个回答
推荐于2016-08-09
展开全部
答案是可以修改的.你新建一个工程,将UIWindow的rootViewController设置为一个UINavigationController的实列,然后自定义一个控制器CustomVC,在CustomVC中写如下代码:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSLog(@"修改前");
[self printViewHierarchy:self.navigationController.navigationBar];
//修改NavigaionBar的高度
self.navigationController.navigationBar.frame = CGRectMake(0,20,320,100);
NSLog(@"\n修改后");
[self printViewHierarchy:self.navigationController.navigationBar];
}
- (void)printViewHierarchy:(UIView *)superView
{
static uint level = 0;
for(uint i = 0; i < level; i++){
printf("\t");
}
const char *className = NSStringFromClass([superView class]).UTF8String;
const char *frame = NSStringFromCGRect(superView.frame).UTF8String;
printf("%s:%s\n",className,frame);
++level;
for(UIView *view in superView.subviews){
[self printViewHierarchy:view];
}
--level;
}
输出结果:
UINavigationBar:{{0,20},{320,44}}
_UINavigationBarBackground:{{0,0},{320,44}}
UIImageView:{{0,44},{320,3}}
UINavigationItemView:{{160,22},{0,0}}
2013-10-29 20:24:36.900 Nav[8957:907]
修改后
UINavigationBar:{{0,20},{320,100}}
_UINavigationBarBackground:{{0,0},{320,100}}
UIImageView:{{0,100},{320,3}}
UINavigationItemView:{{160,22},{0,0}}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
NSLog(@"修改前");
[self printViewHierarchy:self.navigationController.navigationBar];
//修改NavigaionBar的高度
self.navigationController.navigationBar.frame = CGRectMake(0,20,320,100);
NSLog(@"\n修改后");
[self printViewHierarchy:self.navigationController.navigationBar];
}
- (void)printViewHierarchy:(UIView *)superView
{
static uint level = 0;
for(uint i = 0; i < level; i++){
printf("\t");
}
const char *className = NSStringFromClass([superView class]).UTF8String;
const char *frame = NSStringFromCGRect(superView.frame).UTF8String;
printf("%s:%s\n",className,frame);
++level;
for(UIView *view in superView.subviews){
[self printViewHierarchy:view];
}
--level;
}
输出结果:
UINavigationBar:{{0,20},{320,44}}
_UINavigationBarBackground:{{0,0},{320,44}}
UIImageView:{{0,44},{320,3}}
UINavigationItemView:{{160,22},{0,0}}
2013-10-29 20:24:36.900 Nav[8957:907]
修改后
UINavigationBar:{{0,20},{320,100}}
_UINavigationBarBackground:{{0,0},{320,100}}
UIImageView:{{0,100},{320,3}}
UINavigationItemView:{{160,22},{0,0}}
ZESTRON
2024-09-04 广告
2024-09-04 广告
在Dr. O.K. Wack Chemie GmbH,我们高度重视ZESTRON的表界面分析技术。该技术通过深入研究材料表面与界面的性质,为提升产品质量与可靠性提供了有力支持。ZESTRON的表界面分析不仅涵盖了相变化、化学反应、吸附与解吸...
点击进入详情页
本回答由ZESTRON提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询