当应用程序从多任务处理中返回时,自定义 UINavigation 图像消失
我有一个类别可以在应用程序的 UINavigationBar 中显示自定义图像。当应用程序从后台返回时,图像有时会消失,我只剩下带有按钮的白色导航栏。
我正在使用的类别如下,有人可以建议吗?
@implementation UINavigationBar (CustomImage)
-(void)drawRect:(CGRect)rect {
cardSmartAppDelegate *delegate = (cardSmartAppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.navImage drawInRect:rect];
}
@end
I have a category to display a custom image in an app's UINavigationBar. When the app comes back from the background the image sometimes disappears and all I am left with is a white navigation bar with buttons.
The category I'm using is below, can anyone advise please?
@implementation UINavigationBar (CustomImage)
-(void)drawRect:(CGRect)rect {
cardSmartAppDelegate *delegate = (cardSmartAppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.navImage drawInRect:rect];
}
@end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应该使用类别来覆盖方法。有时它有效,但通常无效。有传言称它将很快完全停止工作。
请参阅本项目中的我的代码,了解如何执行您想要的操作:
自定义 UINavigationBar 背景
You shouldn't use a category to override a method. Sometimes it works, but often it doesn't. Rumor has it that it will quit working altogether soon.
See my code in this item for how to do what you want:
Custom UINavigationBar Background