Functions
The following functions are available globally.
-
获取相对设计图宽度等比例缩放值
Declaration
Objective-C
extern CGFloat FWRelativeValue(CGFloat value)
-
获取相对设计图高度等比例缩放值
Declaration
Objective-C
extern CGFloat FWRelativeHeight(CGFloat value)
-
获取相对设计图等比例缩放size
Declaration
Objective-C
extern CGSize FWRelativeSize(CGSize size)
-
获取相对设计图等比例缩放point
Declaration
Objective-C
extern CGPoint FWRelativePoint(CGPoint point)
-
获取相对设计图等比例缩放rect
Declaration
Objective-C
extern CGRect FWRelativeRect(CGRect rect)
-
获取相对设计图等比例缩放insets
Declaration
Objective-C
extern UIEdgeInsets FWRelativeInsets(UIEdgeInsets insets)
-
基于指定的倍数(0取当前设备),对传进来的floatValue进行像素取整
Declaration
Objective-C
static inline CGFloat FWFlatScale(CGFloat floatValue, CGFloat scale)
-
基于当前设备的屏幕倍数,对传进来的floatValue进行像素取整
Declaration
Objective-C
static inline CGFloat FWFlatValue(CGFloat floatValue)
-
自动加载Swift类并调用autoload方法,参数为Class或String
Declaration
Objective-C
extern BOOL FWAutoload(id _Nonnull clazz)
-
安全数字,不为nil
Declaration
Objective-C
extern NSNumber *_Nonnull FWSafeNumber(id _Nullable value)
Parameters
value
参数
Return Value
数字
-
安全字符串,不为nil
Declaration
Objective-C
extern NSString *_Nonnull FWSafeString(id _Nullable value)
Parameters
value
参数
Return Value
字符串
-
安全URL,不为nil
Declaration
Objective-C
extern NSURL *_Nonnull FWSafeURL(id _Nullable value)
Parameters
value
参数
Return Value
URL
-
指定名称和大小初始化图标对象
Declaration
Objective-C
extern FWIcon *_Nullable FWIconNamed(NSString *_Nonnull name, CGFloat size)
-
指定名称和大小初始化图标图像
Declaration
Objective-C
extern UIImage *_Nullable FWIconImage(NSString *_Nonnull name, CGFloat size)
-
快速创建Thin字体
Declaration
Objective-C
extern UIFont *_Nonnull FWFontThin(CGFloat size)
-
快速创建Light字体
Declaration
Objective-C
extern UIFont *_Nonnull FWFontLight(CGFloat size)
-
快速创建Regular字体
Declaration
Objective-C
extern UIFont *_Nonnull FWFontRegular(CGFloat size)
-
快速创建Medium字体
Declaration
Objective-C
extern UIFont *_Nonnull FWFontMedium(CGFloat size)
-
快速创建Semibold字体
Declaration
Objective-C
extern UIFont *_Nonnull FWFontSemibold(CGFloat size)
-
快速创建Bold字体
Declaration
Objective-C
extern UIFont *_Nonnull FWFontBold(CGFloat size)
-
保存图片到指定相册(传入 UIImage)
Declaration
Objective-C
extern void FWImageWriteToSavedPhotosAlbumWithAlbumAssetsGroup( UIImage *_Nonnull image, FWAssetGroup *_Nonnull albumAssetsGroup, FWWriteAssetCompletionBlock _Nonnull completionBlock)
-
保存图片到指定相册(传入图片路径)
Declaration
Objective-C
extern void FWSaveImageAtPathToSavedPhotosAlbumWithAlbumAssetsGroup( NSString *_Nonnull imagePath, FWAssetGroup *_Nonnull albumAssetsGroup, FWWriteAssetCompletionBlock _Nonnull completionBlock)
-
保存视频到指定相册
Declaration
Objective-C
extern void FWSaveVideoAtPathToSavedPhotosAlbumWithAlbumAssetsGroup( NSString *_Nonnull videoPath, FWAssetGroup *_Nonnull albumAssetsGroup, FWWriteAssetCompletionBlock _Nonnull completionBlock)
-
Undocumented
Declaration
Objective-C
void fwAttributedDeallocCallback(void* ref)
-
Undocumented
Declaration
Objective-C
CGFloat fwAttributedAscentCallback(void *ref)
-
Undocumented
Declaration
Objective-C
CGFloat fwAttributedDescentCallback(void *ref)
-
Undocumented
Declaration
Objective-C
CGFloat fwAttributedWidthCallback(void* ref)
-
根据名称加载UIImage,优先加载图片文件(无缓存),文件不存在时尝试系统imageNamed方式(有缓存)
Declaration
Objective-C
extern UIImage *_Nullable FWImageNamed(NSString *_Nonnull name)
-
解析Type-Encoding字符串类型
Declaration
Objective-C
FWEncodingType FWEncodingGetType(const char *_Nonnull typeEncoding)
-
Undocumented
Declaration
Objective-C
FOUNDATION_EXPORT void FWRequestLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2)
-
Returns a localized string representation of an
FWNetworkReachabilityStatus
value.Declaration
Objective-C
extern NSString *_Nonnull FWStringFromNetworkReachabilityStatus( FWNetworkReachabilityStatus status)
-
Returns a percent-escaped string following RFC 3986 for a query string key or value. RFC 3986 states that the following characters are “reserved” characters.
- General Delimiters: “:”, “#”, “[”, “]”, “@”, “?”, “/”
- Sub-Delimiters: “!”, “$”, “&”, “‘”, “(”, “)”, “*”, “+”, “,”, “;”, “=”
In RFC 3986 - Section 3.4, it states that the “?” and “/” characters should not be escaped to allow query strings to include a URL. Therefore, all “reserved” characters with the exception of “?” and “/” should be percent-escaped in the query string.
Declaration
Objective-C
extern NSString *_Nonnull FWPercentEscapedStringFromString( NSString *_Nonnull string)
Parameters
string
The string to be percent-escaped.
Return Value
The percent-escaped string.
-
A helper method to generate encoded url query parameters for appending to the end of a URL.
Declaration
Objective-C
extern NSString *_Nonnull FWQueryStringFromParameters( NSDictionary *_Nonnull parameters)
Parameters
parameters
A dictionary of key/values to be encoded.
Return Value
A url encoded query string
-
Recursively removes
NSNull
values from a JSON object.Declaration
Objective-C
extern id _Nonnull FWJSONObjectByRemovingKeysWithNullValues( id _Nonnull JSONObject, NSJSONReadingOptions readingOptions)
-
Undocumented
Declaration
Objective-C
NSString * FWWebViewJsBridge_js(void)
-
Undocumented
Declaration
Objective-C
FOUNDATION_EXPORT CGFloat FWRadianWithDegree(CGFloat degree)
-
Undocumented
Declaration
Objective-C
FOUNDATION_EXPORT CGFloat FWDegreeWithRadian(CGFloat radian)
-
搜索路径
Declaration
Swift
public func FWPathSearch(_ directory: FileManager.SearchPathDirectory) -> String
Parameters
directory
搜索目录
Return Value
目标路径
-
确保值在固定范围之内
Declaration
Swift
public func FWClamp<T>(_ min: T, _ value: T, _ max: T) -> T where T : Comparable
Parameters
min
最小值
value
当前值
max
最大值
Return Value
范围之内的值