简体   繁体   中英

add subview in navigation bar ios7

I want to add two button and a image view on navigation bar. I written following code for adding image but it is not working.

 UIView *customView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
 UIImageView *logo=[[UIImageView alloc]init];
 logo.image=[UIImage imageNamed:@"sdas.jpeg"];
[customView addSubview:logo];
self.navigationController.navigationItem.titleView=customView;

尝试这个

self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Your Image Name"]];

尝试使用initWithCustomView添加按钮的描述在这里 ,和setBackgroundImage:forMetrics使用这种方式

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM