English 中文(简体)
5. 消除关于航空研究的背景形象 律师
原标题:Remove Background Image on UINavigationBar

我用的是导航控制器,在主页的航标上有一个图像。 通过树立背景形象来实现。

[navigationController.navigationBar setBackgroundImage:navImage forBarMetrics:UIBarMetricsDefault];
[_window addSubview:navigationController.view];

代表。 n球表演了这种形象的精彩。

所有其他观点将而不是在航标上有一个形象。 因此,在推动任何其他观点控制者时,我需要消除这种背景形象。 是否有任何人知道如何做到这一点?

网上有许多关于增加或改变av形形象的答案,但这个问题没有什么不同。 事先感谢你。

最佳回答

I believe this to be the first actual answer to this for iOS5, the main problem being the "removal" of the background image once you are done. Well, just retain the existing image and put it back when you are done.

@implementation MyViewController {
    UIImage *_defaultImage;
}

- (void)viewWillAppear:(BOOL)animated {   
    _defaultImage = [self.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"bar.png"] forBarMetrics:UIBarMetricsDefault];
}

- (void)viewWillDisappear:(BOOL)animated {
    [self.navigationController.navigationBar setBackgroundImage:_defaultImage forBarMetrics:UIBarMetricsDefault];
}
问题回答

消除美国海军陆战队 在5岁或5岁以后,你应当这样做:

[navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];

希望会有助于

你们能够用在运行时间产生的空白形象树立背景形象。

UIGraphicsBeginImageContextWithOptions(CGSizeMake(36, 36), NO, 0.0);
UIImage *blank = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[UINavigationBar appearance] setBackgroundImage:blank forBarMetrics:UIBarMetricsDefault];

Creating blank image in runtime: How to create a blank transparent png in Objective-C?

这样做最容易的方法是:

(1) 在主页上将导航条码打到0.000001

2) 将背景图像列入“背后”航标书(现在很清楚)。

3) 参考 如果意见被推移/散布,将让航道的不透明性达到1或0.00001。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签