ios7以上版本怎么自定义navigationBar的高度
1个回答
展开全部
新建工程UIWindowrootViewController设置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. 疑问请追问没请采纳谢谢
o
- (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. 疑问请追问没请采纳谢谢
o
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
威孚半导体技术
2024-08-19 广告
2024-08-19 广告
威孚(苏州)半导体技术有限公司是一家专注生产、研发、销售晶圆传输设备整机模块(EFEM/SORTER)及核心零部件的高科技半导体公司。公司核心团队均拥有多年半导体行业从业经验,其中技术团队成员博士、硕士学历占比80%以上,依托丰富的软件底层...
点击进入详情页
本回答由威孚半导体技术提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询