只隐藏一些UINavigationController的NavigationBar?
我知道如何隐藏 navigationController 的 navigationBar:
@implementation UINavigationBar (custom)
- (void)drawRect:(CGRect)rect {}
@end
但是,当显示 UIImagePickerController 时,它也适用于它。
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.navigationBar.tintColor = [UIColor blackColor];
picker.navigationBar.barStyle = UIBarStyleBlackOpaque; // Or whatever style.
[self presentModalViewController:picker animated:NO];
有没有办法只让navigationController的navigationBar的一些部分透明?
谢谢。
I know how to make a navigationController's navigationBar hidden:
@implementation UINavigationBar (custom)
- (void)drawRect:(CGRect)rect {}
@end
However, when displaying a UIImagePickerController it also applied to it.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.navigationBar.tintColor = [UIColor blackColor];
picker.navigationBar.barStyle = UIBarStyleBlackOpaque; // Or whatever style.
[self presentModalViewController:picker animated:NO];
Is there a way to only make some of the navigationController's navigationBar transparent?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您需要 -drawRect: 对于 UINavigationBar 的不同实例有不同的行为,您可以使用诸如
objc_setAssociatedObject
之类的东西来记录一些指示它是否应该透明的指示符。然后在-drawRect:
中,您可以在self
上使用objc_getAssociatedObject
来了解要做什么。If you need
-drawRect:
to behave differently for different instances of UINavigationBar, you could use something likeobjc_setAssociatedObject
to record some indicator of whether it should be transparent. Then in-drawRect:
you can useobjc_getAssociatedObject
onself
to find out what to do.