iphone – 如何检测iOS设备是否支持模糊效果?

iphone – 如何检测iOS设备是否支持模糊效果?,第1张

概述看来不同的iOS设备使用barStyle = UIBarStyleBlack和translucent = YES呈现UINavigationBars的方式非常不同.考虑: iPhone 4,没有色调: iPhone 5,没有色调: iPhone 4,barTintColor = [UIColor colorWithWhite:0.0f alpha:0.5f]: iPhone 5,barTintCo 看来不同的iOS设备使用barStyle = UIbarStyleBlack和translucent = YES呈现UINavigationbars的方式非常不同.考虑:

iPhone 4,没有色调:

iPhone 5,没有色调:

iPhone 4,barTintcolor = [UIcolor colorWithWhite:0.0f Alpha:0.5f]:

iPhone 5,barTintcolor = [UIcolor colorWithWhite:0.0f Alpha:0.5f]:

iPhone 5在没有色调的情况下产生所需的效果,但4是不透明的.添加半透明色调使4看起来很好,但拧紧5.

iPad 2和3也是如此,理论上任何不支持iOS 7模糊效果的设备也是如此.

如果没有将这些旧设备列入黑名单,我如何检测设备是否支持模糊,以便我可以有条件地解决渲染差异?或者有没有办法在不使用色调的情况下标准化外观?

解决方法 那个UIDevice类别以及观察UIAccessibilityReduceTransparencyStatusDIDChangeNotification怎么样?

@interface UIDevice (Additions)@property (Readonly) Nsstring *platform;@property (Readonly) BOol canBlur;@end@implementation UIDevice (Additions)- (Nsstring *)platform {    int mib[] = { CTL_HW,HW_MACHINE };    size_t len = 0;    sysctl(mib,2,NulL,&len,0);    char *machine = malloc(len);    sysctl(mib,machine,0);    Nsstring *platform = [Nsstring stringWithCString:machine enCoding:NSASCIIStringEnCoding];    free(machine);    return platform;}- (BOol)canBlur {    if(NsstringFromClass([UIVisualEffectVIEw class]) && UIDevice.currentDevice.systemVersion.floatValue >= 8.0 && !UIAccessibilityIsReduceTransparencyEnabled()) {        Nsstring *platform = self.platform;        CGfloat deviceVersion = [[[platform stringByReplacingOccurrencesOfString:@"[^0-9,.]" withString:@"" options:NSRegularExpressionSearch range:NSMakeRange(0,platform.length)] stringByReplacingOccurrencesOfString:@"," withString:@"."] floatValue];        if([platform isEqualToString:@"i386"] || [platform isEqualToString:@"x86_64"]) {            return YES;        } else if([platform rangeOfString:@"iPhone"].location != NSNotFound) {            return (deviceVersion >= 4.1);        } else if([platform rangeOfString:@"iPod"].location != NSNotFound) {            return (deviceVersion >= 5.1);        } else if([platform rangeOfString:@"iPad"].location != NSNotFound) {            return (deviceVersion >= 3.4);        }    }    return NO;}

不要忘记在实现文件中使用#include.

总结

以上是内存溢出为你收集整理的iphone – 如何检测iOS设备是否支持模糊效果?全部内容,希望文章能够帮你解决iphone – 如何检测iOS设备是否支持模糊效果?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1086197.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存