我在运行iOS 7的iPhone 4上的应用程序使用带有自定义的UITabBar barTintColor
。如Apple文档中所述:https : //developer.apple.com/library/ios/documentation/userexperience/conceptual/UIKitUICatalog/UITabBar.html
默认情况下,iOS 7上的标签栏是半透明的。此外,所有标签栏都存在系统模糊。这样,您的内容就可以在栏下方显示。
但是,这种系统模糊在iPhone 4上不可见,并且UITabBar
在设备上变得透明,如下所示:
我相信这可能是由于iPhone 4中的GPU较弱而发生的,因此它必须回到透明而不是半透明的状态。参考:http : //arstechnica.com/apple/2013/09/new-lease-on-life-or-death-sentence-ios-7-on-the-iphone-4/
一个简单的解决方案可以是有条件地UITabBar
translucent
为iPhone 4制造。但是,我不想知道这种依赖于设备类型的原因,而是想知道我是否可以通过某种方式检测到当GPU弱化时,iOS是否会回到透明状态。 ?(因此使条件更合适)
以下是一些快速和肮脏的类别,用于检测设备是否支持模糊。希望它能解决您的问题
@interface UIToolbar (support)
@property (nonatomic, readonly) BOOL supportsBlur;
@end
@implementation UIToolbar (support)
-(BOOL) supportsBlur{
return [self _supportsBlur:self];
}
-(BOOL)_supportsBlur:(UIView*) view{
if ([view isKindOfClass:NSClassFromString(@"_UIBackdropEffectView")]){
return YES;
}
for (UIView* subview in view.subviews){
if ([self _supportsBlur:subview]){
return YES;
}
}
return NO;
}
@end
// Use this category to detect if the device supports blur
@interface UIDevice (support)
@property (nonatomic, readonly) BOOL supportsBlur;
@end
@implementation UIDevice (support)
-(BOOL) supportsBlur{
static BOOL supportsBlur = NO;
static dispatch_once_t onceToken = 0;
dispatch_once(&onceToken, ^{
UIToolbar* toolBar = [[UIToolbar alloc] init];
[toolBar layoutSubviews];
supportsBlur = toolBar.supportsBlur;
});
return supportsBlur;
}
@end
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句