开发者

Is it possible to add an image icon to a nav bar in a specific view?

开发者 https://www.devze.com 2023-03-20 23:52 出处:网络
Is it possible to add an image to the nav bar? The image should be viewed only in a certain view (i.e. not throughout the application)... Example with an earth icon:

Is it possible to add an image to the nav bar? The image should be viewed only in a certain view (i.e. not throughout the application)... Example with an earth icon:

http://i.stack.imgur.com/FsyH8.png

UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
imgView.image = [UIImage imageNamed: @"1.bmp"];
[self.navigationController.na开发者_Go百科vigationBar addSubview:imgView];
[self.navigationController.navigationBar bringSubviewToFront:imgView];
[imgView release];


Yup! Same way you would add any other subView to a view.

[myNavBar addSubView: myIconView];


You can also add the image in interface builder if you don't want to do it programmatically. Select a button in interface builder and there should be an option to use an image for that item in the Attributes Inspector under "Bar Item"

0

精彩评论

暂无评论...
验证码 换一张
取 消