WXConvert.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. #import <UIKit/UIKit.h>
  20. #import <objc/runtime.h>
  21. #import "WXLog.h"
  22. #import "WXType.h"
  23. @class WXLength;
  24. @class WXBoxShadow;
  25. @interface WXConvert : NSObject
  26. + (BOOL)BOOL:(id)value;
  27. /**
  28. * @abstract convert value to CGFloat value
  29. * @param value value
  30. * @return CGFloat value
  31. */
  32. + (CGFloat)CGFloat:(id)value;
  33. /**
  34. * @abstract convert value to CGFloat value, notice that it will return nan if input value is unsupported
  35. * @param value value
  36. * @return CGFloat value or nan(unsupported input)
  37. */
  38. + (CGFloat)flexCGFloat:(id)value;
  39. + (NSUInteger)NSUInteger:(id)value;
  40. + (NSInteger)NSInteger:(id)value;
  41. + (NSString *)NSString:(id)value;
  42. /**
  43. * 750px Adaptive
  44. */
  45. typedef CGFloat WXPixelType;
  46. // @parameter scaleFactor: please use weexInstance's pixelScaleFactor property
  47. + (WXPixelType)WXPixelType:(id)value scaleFactor:(CGFloat)scaleFactor;
  48. // WXPixelType that use flexCGFloat to convert
  49. + (WXPixelType)WXFlexPixelType:(id)value scaleFactor:(CGFloat)scaleFactor;
  50. + (UIViewContentMode)UIViewContentMode:(id)value;
  51. + (WXImageQuality)WXImageQuality:(id)value;
  52. + (WXImageSharp)WXImageSharp:(id)value;
  53. + (UIAccessibilityTraits)WXUIAccessibilityTraits:(id)value;
  54. + (UIColor *)UIColor:(id)value;
  55. + (CGColorRef)CGColor:(id)value;
  56. + (NSString *)HexWithColor:(UIColor *)color;
  57. + (WXBorderStyle)WXBorderStyle:(id)value;
  58. typedef BOOL WXClipType;
  59. + (WXClipType)WXClipType:(id)value;
  60. + (WXPositionType)WXPositionType:(id)value;
  61. + (WXTextStyle)WXTextStyle:(id)value;
  62. /**
  63. * @abstract UIFontWeightRegular ,UIFontWeightBold,etc are not support by the system which is less than 8.2. weex sdk set the float value.
  64. *
  65. * @param value support normal,blod,100,200,300,400,500,600,700,800,900
  66. *
  67. * @return A float value.
  68. *
  69. */
  70. + (CGFloat)WXTextWeight:(id)value;
  71. + (WXTextDecoration)WXTextDecoration:(id)value;
  72. + (NSTextAlignment)NSTextAlignment:(id)value;
  73. + (UIReturnKeyType)UIReturnKeyType:(id)value;
  74. + (WXScrollDirection)WXScrollDirection:(id)value;
  75. + (UITableViewRowAnimation)UITableViewRowAnimation:(id)value;
  76. + (UIViewAnimationOptions)UIViewAnimationTimingFunction:(id)value;
  77. + (CAMediaTimingFunction *)CAMediaTimingFunction:(id)value;
  78. + (WXVisibility)WXVisibility:(id)value;
  79. + (WXGradientType)gradientType:(id)value;
  80. + (WXLength *)WXLength:(id)value isFloat:(BOOL)isFloat scaleFactor:(CGFloat)scaleFactor;
  81. + (WXBoxShadow *)WXBoxShadow:(id)value scaleFactor:(CGFloat)scaleFactor;
  82. @end
  83. @interface WXConvert (Deprecated)
  84. + (WXPixelType)WXPixelType:(id)value DEPRECATED_MSG_ATTRIBUTE("Use [WXConvert WXPixelType:scaleFactor:] instead");
  85. @end