iOS7 UIStatusBar模糊效果不正确。

5
我正在使用UIToolbar作为屏幕顶部的控件(没有导航控制器)。工具栏外观符合我的要求,但状态栏完全透明。我似乎无法模仿UIToolbar在透明度中具有的模糊效果。是否有人找到了解决方案,而不涉及使用导航控制器?

哦,UIStatusBar。抱歉,我以为你指的是你的“讨论”视图。 - Fogmeister
1个回答

5

UIBarPosition演示

为了实现这个功能,您需要在UIBarPositioningDelegate协议中实现方法:

https://developer.apple.com/library/ios/documentation/uikit/reference/UIBarPositioningDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/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

1
小心不要将cliptobounds设置为YES; - Kyle

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接