我正在尝试将模糊效果添加到导航栏和状态栏.我的问题是导航栏上的模糊很好,但状态栏不会模糊.
我的问题是:如何扩展边界以包含状态栏?
我正在使用以下方法来创建模糊效果:
- (void) addBlurEffect {
CGRect bounds = self.navigationController.navigationBar.bounds;
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
visualEffectView.frame = bounds;
visualEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.navigationController.navigationBar addSubview:visualEffectView];
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
[self.navigationController.navigationBar sendSubviewToBack:visualEffectView];
Run Code Online (Sandbox Code Playgroud)
}
在我的plist中,我有基于View控制器的状态栏外观 YES
在viewDidLoad中我调用一个方法:
- (void)configureView {
// style controls
self.addAirportButton.tintColor = [UIColor whiteColor];
// style background image
UIImageView *sidebarBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sidebarBackground"]];
self.tableView.backgroundView = sidebarBackground;
// style navigation bar
self.navigationController.navigationBar.barStyle = UIStatusBarStyleLightContent;
// this makes navigation bar transparent
[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage …Run Code Online (Sandbox Code Playgroud)