我正在使用UIToolbar作为屏幕顶部的控件(没有导航控制器)。工具栏外观符合我的要求,但状态栏完全透明。我似乎无法模仿UIToolbar在透明度中具有的模糊效果。是否有人找到了解决方案,而不涉及使用导航控制器?
为了实现这个功能,您需要在UIBarPositioningDelegate协议中实现方法:
以下是代码:
@interface ViewController : UIViewController <UIToolbarDelegate>
@property (nonatomic, weak) IBOutlet UIToolbar * toolbar;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
//we become the delegate
self.toolbar.delegate = self;
}
-(UIBarPosition)positionForBar:(id<UIBarPositioning>)bar{
//this tells our bar to extend its background to the top.
return UIBarPositionTopAttached;
}
@end