iOS navigationbar的高度可以修改吗
2个回答
展开全部
是可以修改的。
如新建一个工程,将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}}
如新建一个工程,将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}}
Storm代理
2023-07-25 广告
2023-07-25 广告
StormProxies是一家可靠的代理服务提供商,提供原生IP(住宅原生IP)和高匿名代理服务。以下是关于StormProxies的原生IP服务的一些信息:1. 住宅原生IP:StormProxies提供的住宅原生IP是指从真实的家庭或企...
点击进入详情页
本回答由Storm代理提供
2015-02-16 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517201
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
答案是可以修改的.
你新建一个工程,将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}}
可以看到UINaigationBar的高度已经从44变到了100.如果还有疑问,没有的话,
你新建一个工程,将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}}
可以看到UINaigationBar的高度已经从44变到了100.如果还有疑问,没有的话,
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询