Functions

The following functions are available globally.

FWScreenClassWrapper+FWAdaptive

  • 获取相对设计图宽度等比例缩放值

    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)

FWSafeValue

  • 安全数字,不为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)

FWFontWrapper+FWToolkit

  • 快速创建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)
  • 自动加载Swift类并调用autoload方法,参数为Class或String

    Declaration

    Swift

    @discardableResult
    public func FWAutoload(_ clazz: Any) -> Bool
  • 标记时间调试开始

    Declaration

    Swift

    public func FWBenchmarkBegin(_ name: String = "")

    Parameters

    name

    调试标签,默认空字符串

  • 标记时间调试结束并打印消耗时间

    Declaration

    Swift

    @discardableResult
    public func FWBenchmarkEnd(_ name: String = "") -> TimeInterval

    Parameters

    name

    调试标签,默认空字符串

    Return Value

    消耗时间

  • 记录跟踪日志

    Declaration

    Swift

    public func FWLogTrace(_ format: String, _ arguments: CVarArg..., file: String = #file, function: String = #function, line: Int = #line)

    Parameters

    format

    格式化字符串

    arguments

    可变参数列表,可不传

    file

    文件名,默认传参

    function

    方法名,默认传参

    line

    行数,默认传参

  • 记录调试日志

    Declaration

    Swift

    public func FWLogDebug(_ format: String, _ arguments: CVarArg..., file: String = #file, function: String = #function, line: Int = #line)

    Parameters

    format

    格式化字符串

    arguments

    可变参数列表,可不传

    file

    文件名,默认传参

    function

    方法名,默认传参

    line

    行数,默认传参

  • 记录信息日志

    Declaration

    Swift

    public func FWLogInfo(_ format: String, _ arguments: CVarArg..., file: String = #file, function: String = #function, line: Int = #line)

    Parameters

    format

    格式化字符串

    arguments

    可变参数列表,可不传

    file

    文件名,默认传参

    function

    方法名,默认传参

    line

    行数,默认传参

  • 记录警告日志

    Declaration

    Swift

    public func FWLogWarn(_ format: String, _ arguments: CVarArg..., file: String = #file, function: String = #function, line: Int = #line)

    Parameters

    format

    格式化字符串

    arguments

    可变参数列表,可不传

    file

    文件名,默认传参

    function

    方法名,默认传参

    line

    行数,默认传参

  • 记录错误日志

    Declaration

    Swift

    public func FWLogError(_ format: String, _ arguments: CVarArg..., file: String = #file, function: String = #function, line: Int = #line)

    Parameters

    format

    格式化字符串

    arguments

    可变参数列表,可不传

    file

    文件名,默认传参

    function

    方法名,默认传参

    line

    行数,默认传参

  • 记录分组日志

    Declaration

    Swift

    public func FWLogGroup(_ group: String, type: FWLogType, format: String, _ arguments: CVarArg..., file: String = #file, function: String = #function, line: Int = #line)

    Parameters

    group

    日志分组名称

    type

    日志类型

    format

    格式化字符串

    arguments

    可变参数列表,可不传

    file

    文件名,默认传参

    function

    方法名,默认传参

    line

    行数,默认传参

  • 仿协程异步执行方法

    Declaration

    Swift

    @discardableResult
    public func fw_async(_ block: @escaping () throws -> Any?) -> FWPromise
  • 仿协程同步返回结果

    Declaration

    Swift

    @discardableResult
    public func fw_await(_ promise: FWPromise) throws -> Any?

FWSafeValue

FWSafeType

Comparable

  • Undocumented

    Declaration

    Swift

    public func == (lhs: FWJSON, rhs: FWJSON) -> Bool
  • Undocumented

    Declaration

    Swift

    public func <= (lhs: FWJSON, rhs: FWJSON) -> Bool
  • Undocumented

    Declaration

    Swift

    public func >= (lhs: FWJSON, rhs: FWJSON) -> Bool
  • Undocumented

    Declaration

    Swift

    public func > (lhs: FWJSON, rhs: FWJSON) -> Bool
  • Undocumented

    Declaration

    Swift

    public func < (lhs: FWJSON, rhs: FWJSON) -> Bool
  • 读取本地化字符串

    Declaration

    Swift

    public func FWLocalizedString(_ key: String, _ table: String? = nil) -> String

    Parameters

    key

    本地化键名

    table

    本地化表名,默认Localizable.strings

    Return Value

    本地化字符串

UIDevice+FWAdaptive

  • 是否是指定iOS主版本

    Declaration

    Swift

    public func FWIsIos(_ version: Int) -> Bool
  • 是否是大于等于指定iOS主版本

    Declaration

    Swift

    public func FWIsIosLater(_ version: Int) -> Bool

UIScreen+FWAdaptive

UIColor+FWToolkit

  • 从16进制创建UIColor

    Declaration

    Swift

    public func FWColorHex(_ hex: Int, _ alpha: CGFloat = 1.0) -> UIColor

    Parameters

    hex

    十六进制值,格式0xFFFFFF

    alpha

    透明度可选,默认1.0

    Return Value

    UIColor

  • 从RGB创建UIColor

    Declaration

    Swift

    public func FWColorRgb(_ red: CGFloat, _ green: CGFloat, _ blue: CGFloat, _ alpha: CGFloat = 1.0) -> UIColor

    Parameters

    red

    红色值

    green

    绿色值

    blue

    蓝色值

    alpha

    透明度可选,默认1.0

    Return Value

    UIColor

UIFont+FWToolkit

  • 快速创建系统字体

    Declaration

    Swift

    public func FWFontSize(_ size: CGFloat, _ weight: UIFont.Weight = .regular) -> UIFont

    Parameters

    size

    字体字号

    weight

    字重可选,默认Regular

    Return Value

    UIFont