iOS7 UIStatusBar blur not correct

懵懂的女人 提交于 2019-12-23 10:51:53

问题


I am using a UIToolbar for the controls at the top of the screen (There is no navigation controller) The toolbar has the look I want, however the status bar is entirely clear. I cannot seem to mimic the blur that the UIToolbar has in it's transparency. Has anyone come across a solution to this that does not involve using a navigation controller?


回答1:


In Order to achieve this you need to implement methods in the UIBarPositioningDelegate protocol:

https://developer.apple.com/library/ios/documentation/uikit/reference/UIBarPositioningDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UIBarPositioningDelegate

Here is the code:

@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


来源:https://stackoverflow.com/questions/18920703/ios7-uistatusbar-blur-not-correct

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!