diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXConvert.m b/ios/sdk/WeexSDK/Sources/Utility/WXConvert.m index c497d280c8..b0de541875 100644 --- a/ios/sdk/WeexSDK/Sources/Utility/WXConvert.m +++ b/ios/sdk/WeexSDK/Sources/Utility/WXConvert.m @@ -503,32 +503,32 @@ + (WXTextStyle)WXTextStyle:(id)value + (CGFloat)WXTextWeight:(id)value { - if([value isKindOfClass:[NSString class]]){ - NSString *string = (NSString *)value; - if ([string isEqualToString:@"normal"]) - return WX_SYS_VERSION_LESS_THAN(@"8.2")?0:UIFontWeightRegular; - else if ([string isEqualToString:@"bold"]) - return WX_SYS_VERSION_LESS_THAN(@"8.2")?0.4:UIFontWeightBold; - else if ([string isEqualToString:@"100"]) - return WX_SYS_VERSION_LESS_THAN(@"8.2")?-0.8:UIFontWeightUltraLight; - else if ([string isEqualToString:@"200"]) - return WX_SYS_VERSION_LESS_THAN(@"8.2")?-0.6:UIFontWeightThin; - else if ([string isEqualToString:@"300"]) - return WX_SYS_VERSION_LESS_THAN(@"8.2")?-0.4:UIFontWeightLight; - else if ([string isEqualToString:@"400"]) - return WX_SYS_VERSION_LESS_THAN(@"8.2")?0:UIFontWeightRegular; - else if ([string isEqualToString:@"500"]) - return WX_SYS_VERSION_LESS_THAN(@"8.2")?0.23:UIFontWeightMedium; - else if ([string isEqualToString:@"600"]) - return WX_SYS_VERSION_LESS_THAN(@"8.2")?0.3:UIFontWeightSemibold; - else if ([string isEqualToString:@"700"]) - return WX_SYS_VERSION_LESS_THAN(@"8.2")?0.4:UIFontWeightBold; - else if ([string isEqualToString:@"800"]) - return WX_SYS_VERSION_LESS_THAN(@"8.2")?0.56:UIFontWeightHeavy; - else if ([string isEqualToString:@"900"]) - return WX_SYS_VERSION_LESS_THAN(@"8.2")?0.62:UIFontWeightBlack; - - } + NSString *string = [WXConvert NSString:value]; + if (!string) + return WX_SYS_VERSION_LESS_THAN(@"8.2")?0:UIFontWeightRegular; + else if ([string isEqualToString:@"normal"]) + return WX_SYS_VERSION_LESS_THAN(@"8.2")?0:UIFontWeightRegular; + else if ([string isEqualToString:@"bold"]) + return WX_SYS_VERSION_LESS_THAN(@"8.2")?0.4:UIFontWeightBold; + else if ([string isEqualToString:@"100"]) + return WX_SYS_VERSION_LESS_THAN(@"8.2")?-0.8:UIFontWeightUltraLight; + else if ([string isEqualToString:@"200"]) + return WX_SYS_VERSION_LESS_THAN(@"8.2")?-0.6:UIFontWeightThin; + else if ([string isEqualToString:@"300"]) + return WX_SYS_VERSION_LESS_THAN(@"8.2")?-0.4:UIFontWeightLight; + else if ([string isEqualToString:@"400"]) + return WX_SYS_VERSION_LESS_THAN(@"8.2")?0:UIFontWeightRegular; + else if ([string isEqualToString:@"500"]) + return WX_SYS_VERSION_LESS_THAN(@"8.2")?0.23:UIFontWeightMedium; + else if ([string isEqualToString:@"600"]) + return WX_SYS_VERSION_LESS_THAN(@"8.2")?0.3:UIFontWeightSemibold; + else if ([string isEqualToString:@"700"]) + return WX_SYS_VERSION_LESS_THAN(@"8.2")?0.4:UIFontWeightBold; + else if ([string isEqualToString:@"800"]) + return WX_SYS_VERSION_LESS_THAN(@"8.2")?0.56:UIFontWeightHeavy; + else if ([string isEqualToString:@"900"]) + return WX_SYS_VERSION_LESS_THAN(@"8.2")?0.62:UIFontWeightBlack; + return WX_SYS_VERSION_LESS_THAN(@"8.2")?0:UIFontWeightRegular; }