Wrapper

extension Wrapper where Base: UINavigationController
extension Wrapper where Base: UIViewController
extension Wrapper where Base: UINavigationBar
extension Wrapper where Base: UIView
extension Wrapper where Base: UIProgressView
extension Wrapper where Base: WKWebView
extension Wrapper where Base: NSObject
extension Wrapper where Base: UIAlertAction
extension Wrapper where Base: UIAlertController
extension Wrapper where Base: UIScrollView
extension Wrapper where Base: PHPhotoLibrary
extension Wrapper where Base: UIImage
extension Wrapper where Base: UIImagePickerController
extension Wrapper where Base: PHPickerViewController
extension Wrapper where Base: UIImageView
extension Wrapper where Base: UIWindow
extension Wrapper where Base: UIActivityIndicatorView
extension Wrapper where Base == Data
extension Wrapper where Base: NSMutableAttributedString
extension Wrapper where Base: UIBarItem
extension Wrapper where Base: UIBarButtonItem
extension Wrapper where Base: UITabBarItem
extension Wrapper where Base: CALayer
extension Wrapper where Base: UICollectionViewFlowLayout
extension Wrapper where Base: Bundle
extension Wrapper where Base == Date
extension Wrapper where Base: FileManager
extension Wrapper where Base: NSAttributedString
extension Wrapper where Base: NSNumber
extension Wrapper where Base == String
extension Wrapper where Base == URL
extension Wrapper where Base == URLRequest
extension Wrapper where Base: UIApplication
extension Wrapper where Base: UIBezierPath
extension Wrapper where Base: UIControl
extension Wrapper where Base: UIButton
extension Wrapper where Base: UISwitch
extension Wrapper where Base: UICollectionView
extension Wrapper where Base: UIColor
extension Wrapper where Base: UIDevice
extension Wrapper where Base: UIFont
extension Wrapper where Base: UILabel
extension Wrapper where Base: UNUserNotificationCenter
extension Wrapper where Base: UIToolbar
extension Wrapper where Base: UIGestureRecognizer
extension Wrapper where Base: UIPanGestureRecognizer
extension Wrapper where Base: UISearchBar
extension Wrapper where Base: UITableView
extension Wrapper where Base: UITableViewCell
extension Wrapper where Base: UITextField
extension Wrapper where Base: UITextView
extension Wrapper where Base: CAGradientLayer

Available where Base: UINavigationController

  • 自定义转场过程中containerView的背景色,默认透明

    Declaration

    Swift

    public var containerBackgroundColor: UIColor { get set }
  • 全局启用NavigationBar转场。启用后各个ViewController管理自己的导航栏样式,在viewDidLoad或viewViewAppear中设置即可

    Declaration

    Swift

    public static func enableBarTransition()
  • 是否启用导航栏全屏返回手势,默认NO。启用时系统返回手势失效,禁用时还原系统手势。如果只禁用系统手势,设置interactivePopGestureRecognizer.enabled即可

    Declaration

    Swift

    public var fullscreenPopGestureEnabled: Bool { get set }
  • 导航栏全屏返回手势对象

    Declaration

    Swift

    public var fullscreenPopGestureRecognizer: UIPanGestureRecognizer { get }
  • 判断手势是否是全局返回手势对象

    Declaration

    Swift

    public static func isFullscreenPopGestureRecognizer(_ gestureRecognizer: UIGestureRecognizer) -> Bool

Available where Base: UIViewController

  • 转场动画自定义判断标识,不相等才会启用转场。默认nil启用转场。可重写或者push前设置生效

    Declaration

    Swift

    public var barTransitionIdentifier: Any? { get set }
  • 视图控制器是否禁用全屏返回手势,默认NO

    Declaration

    Swift

    public var fullscreenPopGestureDisabled: Bool { get set }
  • 视图控制器全屏手势距离左侧最大距离,默认0,无限制

    Declaration

    Swift

    public var fullscreenPopGestureDistance: CGFloat { get set }

Available where Base: UINavigationBar

  • 导航栏背景视图,显示背景色和背景图片等

    Declaration

    Swift

    public var backgroundView: UIView? { get }
  • 应用指定导航栏配置

    Declaration

    Swift

    public func applyBarAppearance(_ appearance: NavigationBarAppearance)
  • 应用指定导航栏样式

    Declaration

    Swift

    public func applyBarStyle(_ style: NavigationBarStyle)

Available where Base: UIViewController

  • 状态栏样式,默认UIStatusBarStyleDefault,设置后才会生效

    Declaration

    Swift

    public var statusBarStyle: UIStatusBarStyle { get set }
  • 状态栏是否隐藏,默认NO,设置后才会生效

    Declaration

    Swift

    public var statusBarHidden: Bool { get set }
  • 当前导航栏设置,优先级高于style,设置后会在viewWillAppear:自动应用生效

    Declaration

    Swift

    public var navigationBarAppearance: NavigationBarAppearance? { get set }
  • 当前导航栏样式,默认Default,设置后才会在viewWillAppear:自动应用生效

    Declaration

    Swift

    public var navigationBarStyle: NavigationBarStyle { get set }
  • 导航栏是否隐藏,默认NO,设置后才会在viewWillAppear:自动应用生效

    Declaration

    Swift

    public var navigationBarHidden: Bool { get set }
  • 动态隐藏导航栏,如果当前已经viewWillAppear:时立即执行

    Declaration

    Swift

    public func setNavigationBarHidden(_ hidden: Bool, animated: Bool)
  • 是否允许child控制器修改导航栏样式,默认false

    Declaration

    Swift

    public var allowsChildNavigation: Bool { get set }
  • 标签栏是否隐藏,默认为NO,立即生效。如果tabBar一直存在,则用tabBar包裹navBar;如果tabBar只存在主界面,则用navBar包裹tabBar

    Declaration

    Swift

    public var tabBarHidden: Bool { get set }
  • 工具栏是否隐藏,默认为YES。需设置toolbarItems,立即生效

    Declaration

    Swift

    public var toolBarHidden: Bool { get set }
  • 动态隐藏工具栏。需设置toolbarItems,立即生效

    Declaration

    Swift

    public func setToolBarHidden(_ hidden: Bool, animated: Bool)
  • 设置视图布局Bar延伸类型,None为不延伸(Bar不覆盖视图),Top|Bottom为顶部|底部延伸,All为全部延伸

    Declaration

    Swift

    public var extendedLayoutEdge: UIRectEdge { get set }
  • 视图控制器present|dismiss转场。注意会修改transitioningDelegate,且会强引用之;如需weak引用,请直接设置transitioningDelegate

    Declaration

    Swift

    public var modalTransition: AnimatedTransition? { get set }
  • 视图控制器push|pop转场,代理导航控制器转场,需在fwNavigationTransition设置后生效

    Declaration

    Swift

    public var viewTransition: AnimatedTransition? { get set }
  • 自定义控制器present系统转场(蒙层渐变,内容向上动画),会设置fwModalTransition

    Declaration

    Swift

    @discardableResult
    public func setPresentTransition(_ presentationBlock: ((PresentationController) -> Void)?) -> AnimatedTransition
  • 自定义控制器alert缩放转场(蒙层渐变,内容缩放动画),会设置fwModalTransition

    Declaration

    Swift

    @discardableResult
    public func setAlertTransition(_ presentationBlock: ((PresentationController) -> Void)?) -> AnimatedTransition
  • 自定义控制器fade渐变转场(蒙层和内容渐变动画),会设置fwModalTransition;

    Declaration

    Swift

    @discardableResult
    public func setFadeTransition(_ presentationBlock: ((PresentationController) -> Void)?) -> AnimatedTransition
  • 设置iOS13默认present手势下拉dismiss时的回调block,仅iOS13生效,自动触发,手工dismiss不会触发。会自动设置presentationController.delegate

    Declaration

    Swift

    public var presentationDidDismiss: (() -> Void)? { get set }
  • 自定义控制器popover弹出效果(preferredContentSize设置大小),会自动设置modalPresentationStyle和popoverPresentationController.delegate

    Declaration

    Swift

    public func setPopoverPresentation(_ presentationBlock: ((UIPopoverPresentationController) -> Void)?, shouldDismiss: Bool)

Available where Base: UIView

  • 转场添加到指定控制器(pinEdges占满父视图),返回父容器视图。VC.tabBarController.view > VC.navigationController.view > VC.view

    Declaration

    Swift

    public func transition(to viewController: UIViewController, pinEdges: Bool) -> UIView
  • 包装到转场控制器(pinEdges占满父视图),返回创建的控制器

    Declaration

    Swift

    public func wrappedTransitionController(_ pinEdges: Bool) -> UIViewController
  • 自定义视图模拟present系统转场(蒙层渐变,内容向上动画)

    Declaration

    Swift

    public func setPresentTransition(_ transitionType: AnimatedTransitionType, contentView: UIView?, completion: ((Bool) -> Void)?)
  • 自定义视图模拟alert缩放转场(蒙层渐变,内容缩放动画)

    Declaration

    Swift

    public func setAlertTransition(_ transitionType: AnimatedTransitionType, completion: ((Bool) -> Void)?)
  • 自定义视图模拟fade渐变转场(蒙层和内容渐变动画)

    Declaration

    Swift

    public func setFadeTransition(_ transitionType: AnimatedTransitionType, completion: ((Bool) -> Void)?)

Available where Base: UINavigationController

  • 导航控制器push|pop转场。注意会修改delegate,且会强引用之,一直生效直到设置为nil。如需weak引用,请直接设置delegate

    Declaration

    Swift

    public var navigationTransition: AnimatedTransition? { get set }

Available where Base: UIProgressView

  • 设置Web加载进度,0和1自动切换隐藏。可设置trackTintColor为clear,隐藏背景色

    Declaration

    Swift

    public var webProgress: Float { get set }

Available where Base: WKWebView

  • 设置Javascript桥接器强引用属性,防止使用过程中被释放

    Declaration

    Swift

    public var jsBridge: WebViewJsBridge? { get set }
  • 获取当前UserAgent,未自定义时为默认,示例:Mozilla/5.0 (iPhone; CPU OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148

    Declaration

    Swift

    public var userAgent: String { get }
  • 获取默认浏览器UserAgent,包含应用信息,示例:Mozilla/5.0 (iPhone; CPU OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Safari/605.1.15 Example/1.0.0

    Declaration

    Swift

    public static var browserUserAgent: String { get }
  • 获取默认浏览器扩展UserAgent,不含平台信息,可用于applicationNameForUserAgent,示例:Mobile/15E148 Safari/605.1.15 Example/1.0.0

    Declaration

    Swift

    public static var extensionUserAgent: String { get }
  • 获取默认请求UserAgent,可用于网络请求,示例:Example/1.0.0 (iPhone; iOS 14.2; Scale/3.00)

    Declaration

    Swift

    public static var requestUserAgent: String { get }
  • 清空网页缓存,完成后回调。单个网页请求指定URLRequest.cachePolicy即可

    Declaration

    Swift

    public static func fw_clearCache(_ completion: (() -> Void)? = nil)

Available where Base: NSObject

  • 从json创建对象,线程安全。NSDate会按照UTC时间解析,下同

    Declaration

    Swift

    public static func model(json: Any) -> Base?

    Parameters

    json

    json对象,支持NSDictionary、NSString、NSData

    Return Value

    实例对象,失败为nil

  • 从字典创建对象,线程安全

    Declaration

    Swift

    public static func model(dictionary: [AnyHashable : Any]) -> Base?

    Parameters

    dictionary

    字典数据

    Return Value

    实例对象,失败为nil

  • 从json创建Model数组

    Declaration

    Swift

    public static func modelArray(json: Any) -> [Base]?

    Parameters

    json

    json对象,支持NSDictionary、NSString、NSData

    Return Value

    Model数组

  • 从json创建Model字典

    Declaration

    Swift

    public static func modelDictionary(json: Any) -> [String : Base]?

    Parameters

    json

    json对象,支持NSDictionary、NSString、NSData

    Return Value

    Model字典

  • 从json对象设置对象属性

    Declaration

    Swift

    @discardableResult
    public func modelSet(json: Any) -> Bool

    Parameters

    json

    json对象,支持NSDictionary、NSString、NSData

    Return Value

    是否设置成功

  • 从字典设置对象属性

    Declaration

    Swift

    @discardableResult
    public func modelSet(dictionary: [AnyHashable : Any]) -> Bool

    Parameters

    dictionary

    字典数据

    Return Value

    是否设置成功

  • 转换为json对象

    Declaration

    Swift

    public func modelToJsonObject() -> Any?

    Return Value

    json对象,如NSDictionary、NSArray,失败为nil

  • 转换为json字符串数据

    Declaration

    Swift

    public func modelToJsonData() -> Data?

    Return Value

    NSData,失败为nil

  • 转换为json字符串

    Declaration

    Swift

    public func modelToJsonString() -> String?

    Return Value

    NSString,失败为nil

  • 从属性拷贝当前对象

    Declaration

    Swift

    public func modelCopy() -> Any?

    Return Value

    拷贝对象,失败为nil

  • 对象编码

    Declaration

    Swift

    public func modelEncode(coder: NSCoder)
  • 对象解码

    Declaration

    Swift

    public func modelInit(coder: NSCoder) -> Any
  • 对象的hash编码

    Declaration

    Swift

    public func modelHash() -> UInt
  • 比较Model

    Declaration

    Swift

    public func modelIsEqual(_ model: Any) -> Bool
  • 对象描述

    Declaration

    Swift

    public func modelDescription() -> String

Available where Base: UIView

  • 通用视图绑定数据,改变时自动触发viewModelChanged和FWView.renderData

    Declaration

    Swift

    public var viewModel: Any? { get set }
  • 通用视图数据改变句柄钩子,viewData改变时自动调用

    Declaration

    Swift

    public var viewModelChanged: ((UIView) -> Void)? { get set }
  • 通用事件接收代理,弱引用,Delegate方式

    Declaration

    Swift

    public weak var viewDelegate: ViewDelegate? { get set }
  • 通用事件接收句柄,Block方式

    Declaration

    Swift

    public var eventReceived: ((UIView, Notification) -> Void)? { get set }
  • 通用事件完成回调句柄,Block方式

    Declaration

    Swift

    public var eventFinished: ((UIView, Notification) -> Void)? { get set }
  • 发送指定事件,通知代理,支持附带对象和用户信息

    Declaration

    Swift

    public func sendEvent(_ name: String, object: Any? = nil, userInfo: [AnyHashable : Any]? = nil)
  • 通知事件完成,自动调用eventFinished句柄和FWView.renderEvent钩子

    Declaration

    Swift

    public func finishEvent(_ notification: Notification)

Available where Base: UIViewController

  • 自定义弹窗插件,未设置时自动从插件池加载

    Declaration

    Swift

    public var alertPlugin: AlertPlugin? { get set }
  • 显示警告框(简单版)

    Declaration

    Swift

    public func showAlert(
        title: Any?,
        message: Any?,
        cancel: Any? = nil,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    警告框标题

    message

    警告框消息

    cancel

    取消按钮标题,默认关闭

    cancelBlock

    取消按钮事件

  • 显示警告框(详细版)

    Declaration

    Swift

    public func showAlert(
        title: Any?,
        message: Any?,
        style: AlertStyle = .default,
        cancel: Any?,
        actions: [Any]?,
        actionBlock: ((Int) -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    警告框标题

    message

    警告框消息

    style

    警告框样式

    cancel

    取消按钮标题,默认单按钮关闭,多按钮取消

    actions

    动作按钮标题列表

    actionBlock

    动作按钮点击事件,参数为索引index

    cancelBlock

    取消按钮事件

  • 显示确认框(简单版)

    Declaration

    Swift

    public func showConfirm(
        title: Any?,
        message: Any?,
        confirmBlock: (() -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    确认框标题

    message

    确认框消息

    confirmBlock

    确认按钮事件

    cancelBlock

    取消按钮事件

  • 显示确认框(详细版)

    Declaration

    Swift

    public func showConfirm(
        title: Any?,
        message: Any?,
        cancel: Any?,
        confirm: Any?,
        confirmBlock: (() -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    确认框标题

    message

    确认框消息

    cancel

    取消按钮文字,默认取消

    confirm

    确认按钮文字,默认确定

    confirmBlock

    确认按钮事件

    cancelBlock

    取消按钮事件

  • 显示输入框(简单版)

    Declaration

    Swift

    public func showPrompt(
        title: Any?,
        message: Any?,
        cancel: Any?,
        confirm: Any?,
        promptBlock: ((UITextField) -> Void)? = nil,
        confirmBlock: ((String) -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    输入框标题

    message

    输入框消息

    cancel

    取消按钮文字,默认取消

    confirm

    确认按钮文字,默认确定

    promptBlock

    输入框初始化事件,参数为输入框

    confirmBlock

    确认按钮事件,参数为输入值

    cancelBlock

    取消按钮事件

  • 显示输入框(详细版)

    Declaration

    Swift

    public func showPrompt(
        title: Any?,
        message: Any?,
        cancel: Any?,
        confirm: Any?,
        promptCount: Int,
        promptBlock: ((UITextField, Int) -> Void)?,
        confirmBlock: (([String]) -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    输入框标题

    message

    输入框消息

    cancel

    取消按钮文字,默认取消

    confirm

    确认按钮文字,默认确定

    promptCount

    输入框数量

    promptBlock

    输入框初始化事件,参数为输入框和索引index

    confirmBlock

    确认按钮事件,参数为输入值数组

    cancelBlock

    取消按钮事件

  • 显示弹出框(完整版)

    Declaration

    Swift

    public func showAlert(
        title: Any?,
        message: Any?,
        style: AlertStyle = .default,
        cancel: Any?,
        actions: [Any]?,
        promptCount: Int,
        promptBlock: ((UITextField, Int) -> Void)?,
        actionBlock: (([String], Int) -> Void)?,
        cancelBlock: (() -> Void)?,
        customBlock: ((Any) -> Void)?
    )

    Parameters

    title

    弹出框标题

    message

    弹出框消息

    style

    警告框样式

    cancel

    取消按钮标题,默认Alert单按钮关闭,Alert多按钮或Sheet取消

    actions

    动作按钮标题列表

    promptCount

    输入框数量

    promptBlock

    输入框初始化事件,参数为输入框和索引index

    actionBlock

    动作按钮点击事件,参数为输入值数组和索引index

    cancelBlock

    取消按钮事件

    customBlock

    自定义弹出框事件

  • 显示操作表(无动作)

    Declaration

    Swift

    public func showSheet(
        title: Any?,
        message: Any?,
        cancel: Any?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    操作表标题

    message

    操作表消息

    cancel

    取消按钮标题,默认取消

    cancelBlock

    取消按钮事件

  • 显示操作表(简单版)

    Declaration

    Swift

    public func showSheet(
        title: Any?,
        message: Any?,
        actions: [Any]?,
        actionBlock: ((Int) -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    操作表标题

    message

    操作表消息

    actions

    动作按钮标题列表

    actionBlock

    动作按钮点击事件,参数为索引index

    cancelBlock

    取消按钮事件

  • 显示操作表(详细版)

    Declaration

    Swift

    public func showSheet(
        title: Any?,
        message: Any?,
        cancel: Any?,
        actions: [Any]?,
        currentIndex: Int,
        actionBlock: ((Int) -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    操作表标题

    message

    操作表消息

    cancel

    取消按钮标题,默认取消

    actions

    动作按钮标题列表

    currentIndex

    当前选中动作索引

    actionBlock

    动作按钮点击事件,参数为索引index

    cancelBlock

    取消按钮事件

  • 显示操作表(完整版)

    Declaration

    Swift

    public func showSheet(
        title: Any?,
        message: Any?,
        cancel: Any?,
        actions: [Any]?,
        currentIndex: Int,
        actionBlock: ((Int) -> Void)?,
        cancelBlock: (() -> Void)?,
        customBlock: ((Any) -> Void)?
    )

    Parameters

    title

    操作表标题

    message

    操作表消息

    cancel

    取消按钮标题,默认Alert单按钮关闭,Alert多按钮或Sheet取消

    actions

    动作按钮标题列表

    currentIndex

    当前选中动作索引

    actionBlock

    动作按钮点击事件,参数为输入值数组和索引index

    cancelBlock

    取消按钮事件

    customBlock

    自定义弹出框事件

  • 手工隐藏弹出框,完成后回调

    Declaration

    Swift

    public func hideAlert(
        animated: Bool,
        completion: (() -> Void)? = nil
    )

    Parameters

    animated

    是否执行动画

    completion

    完成回调

  • 判断是否正在显示弹出框

    Declaration

    Swift

    public var isShowingAlert: Bool { get }

Available where Base: UIView

  • 显示警告框(简单版)

    Declaration

    Swift

    public func showAlert(
        title: Any?,
        message: Any?,
        cancel: Any? = nil,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    警告框标题

    message

    警告框消息

    cancel

    取消按钮标题,默认关闭

    cancelBlock

    取消按钮事件

  • 显示警告框(详细版)

    Declaration

    Swift

    public func showAlert(
        title: Any?,
        message: Any?,
        style: AlertStyle = .default,
        cancel: Any?,
        actions: [Any]?,
        actionBlock: ((Int) -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    警告框标题

    message

    警告框消息

    style

    警告框样式

    cancel

    取消按钮标题,默认单按钮关闭,多按钮取消

    actions

    动作按钮标题列表

    actionBlock

    动作按钮点击事件,参数为索引index

    cancelBlock

    取消按钮事件

  • 显示确认框(简单版)

    Declaration

    Swift

    public func showConfirm(
        title: Any?,
        message: Any?,
        confirmBlock: (() -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    确认框标题

    message

    确认框消息

    confirmBlock

    确认按钮事件

    cancelBlock

    取消按钮事件

  • 显示确认框(详细版)

    Declaration

    Swift

    public func showConfirm(
        title: Any?,
        message: Any?,
        cancel: Any?,
        confirm: Any?,
        confirmBlock: (() -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    确认框标题

    message

    确认框消息

    cancel

    取消按钮文字,默认取消

    confirm

    确认按钮文字,默认确定

    confirmBlock

    确认按钮事件

    cancelBlock

    取消按钮事件

  • 显示输入框(简单版)

    Declaration

    Swift

    public func showPrompt(
        title: Any?,
        message: Any?,
        cancel: Any?,
        confirm: Any?,
        promptBlock: ((UITextField) -> Void)? = nil,
        confirmBlock: ((String) -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    输入框标题

    message

    输入框消息

    cancel

    取消按钮文字,默认取消

    confirm

    确认按钮文字,默认确定

    promptBlock

    输入框初始化事件,参数为输入框

    confirmBlock

    确认按钮事件,参数为输入值

    cancelBlock

    取消按钮事件

  • 显示输入框(详细版)

    Declaration

    Swift

    public func showPrompt(
        title: Any?,
        message: Any?,
        cancel: Any?,
        confirm: Any?,
        promptCount: Int,
        promptBlock: ((UITextField, Int) -> Void)?,
        confirmBlock: (([String]) -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    输入框标题

    message

    输入框消息

    cancel

    取消按钮文字,默认取消

    confirm

    确认按钮文字,默认确定

    promptCount

    输入框数量

    promptBlock

    输入框初始化事件,参数为输入框和索引index

    confirmBlock

    确认按钮事件,参数为输入值数组

    cancelBlock

    取消按钮事件

  • 显示弹出框(完整版)

    Declaration

    Swift

    public func showAlert(
        title: Any?,
        message: Any?,
        style: AlertStyle = .default,
        cancel: Any?,
        actions: [Any]?,
        promptCount: Int,
        promptBlock: ((UITextField, Int) -> Void)?,
        actionBlock: (([String], Int) -> Void)?,
        cancelBlock: (() -> Void)?,
        customBlock: ((Any) -> Void)?
    )

    Parameters

    title

    弹出框标题

    message

    弹出框消息

    style

    弹出框样式

    cancel

    取消按钮标题,默认Alert单按钮关闭,Alert多按钮或Sheet取消

    actions

    动作按钮标题列表

    promptCount

    输入框数量

    promptBlock

    输入框初始化事件,参数为输入框和索引index

    actionBlock

    动作按钮点击事件,参数为输入值数组和索引index

    cancelBlock

    取消按钮事件

    customBlock

    自定义弹出框事件

  • 显示操作表(无动作)

    Declaration

    Swift

    public func showSheet(
        title: Any?,
        message: Any?,
        cancel: Any?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    操作表标题

    message

    操作表消息

    cancel

    取消按钮标题,默认取消

    cancelBlock

    取消按钮事件

  • 显示操作表(简单版)

    Declaration

    Swift

    public func showSheet(
        title: Any?,
        message: Any?,
        actions: [Any]?,
        actionBlock: ((Int) -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    操作表标题

    message

    操作表消息

    actions

    动作按钮标题列表

    actionBlock

    动作按钮点击事件,参数为索引index

    cancelBlock

    取消按钮事件

  • 显示操作表(详细版)

    Declaration

    Swift

    public func showSheet(
        title: Any?,
        message: Any?,
        cancel: Any?,
        actions: [Any]?,
        currentIndex: Int,
        actionBlock: ((Int) -> Void)?,
        cancelBlock: (() -> Void)? = nil
    )

    Parameters

    title

    操作表标题

    message

    操作表消息

    cancel

    取消按钮标题,默认取消

    actions

    动作按钮标题列表

    currentIndex

    当前选中动作索引

    actionBlock

    动作按钮点击事件,参数为索引index

    cancelBlock

    取消按钮事件

  • 显示弹出框(完整版)

    Declaration

    Swift

    public func showSheet(
        title: Any?,
        message: Any?,
        cancel: Any?,
        actions: [Any]?,
        currentIndex: Int,
        actionBlock: ((Int) -> Void)?,
        cancelBlock: (() -> Void)?,
        customBlock: ((Any) -> Void)?
    )

    Parameters

    title

    操作表标题

    message

    操作表消息

    cancel

    取消按钮标题,默认Alert单按钮关闭,Alert多按钮或Sheet取消

    actions

    动作按钮标题列表

    currentIndex

    当前选中动作索引

    actionBlock

    动作按钮点击事件,参数为输入值数组和索引index

    cancelBlock

    取消按钮事件

    customBlock

    自定义弹出框事件

  • 手工隐藏弹出框,完成后回调

    Declaration

    Swift

    public func hideAlert(
        animated: Bool,
        completion: (() -> Void)? = nil
    )

    Parameters

    animated

    是否执行动画

    completion

    完成回调

  • 判断是否正在显示弹出框

    Declaration

    Swift

    public var isShowingAlert: Bool { get }

Available where Base: UIAlertAction

  • 自定义样式,默认为样式单例

    Declaration

    Swift

    public var alertAppearance: AlertAppearance { get set }
  • 指定标题颜色

    Declaration

    Swift

    public var titleColor: UIColor? { get set }
  • 快速创建弹出动作,title仅支持NSString

    Declaration

    Swift

    public static func action(object: Any?, style: UIAlertAction.Style, handler: ((UIAlertAction) -> Void)?) -> UIAlertAction
  • 快速创建弹出动作,title仅支持NSString,支持appearance

    Declaration

    Swift

    public static func action(object: Any?, style: UIAlertAction.Style, appearance: AlertAppearance?, handler: ((UIAlertAction) -> Void)?) -> UIAlertAction

Available where Base: UIAlertController

  • 自定义样式,默认为样式单例

    Declaration

    Swift

    public var alertAppearance: AlertAppearance { get set }
  • 弹出框样式,默认为Default

    Declaration

    Swift

    public var alertStyle: AlertStyle { get set }
  • 设置属性标题

    Declaration

    Swift

    public var attributedTitle: NSAttributedString? { get set }
  • 设置属性消息

    Declaration

    Swift

    public var attributedMessage: NSAttributedString? { get set }
  • 快速创建弹出控制器,title和message仅支持NSString

    Declaration

    Swift

    public static func alertController(title: Any?, message: Any?, preferredStyle: UIAlertController.Style) -> UIAlertController
  • 快速创建弹出控制器,title和message仅支持NSString,支持自定义样式

    Declaration

    Swift

    public static func alertController(title: Any?, message: Any?, preferredStyle: UIAlertController.Style, appearance: AlertAppearance?) -> UIAlertController

Available where Base: UIView

  • 自定义空界面插件,未设置时自动从插件池加载

    Declaration

    Swift

    public var emptyPlugin: EmptyPlugin? { get set }
  • 设置空界面外间距,默认zero

    Declaration

    Swift

    public var emptyInsets: UIEdgeInsets { get set }
  • 是否显示空界面

    Declaration

    Swift

    public var hasEmptyView: Bool { get }
  • 显示空界面

    Declaration

    Swift

    public func showEmptyView()
  • 显示空界面加载视图

    Declaration

    Swift

    public func showEmptyLoading()
  • 显示空界面,指定文本和详细文本

    Declaration

    Swift

    public func showEmptyView(text: String?, detail: String? = nil)
  • 显示空界面,指定文本、详细文本和图片

    Declaration

    Swift

    public func showEmptyView(text: String?, detail: String?, image: UIImage?)
  • 显示空界面,指定文本、详细文本、图片和动作按钮

    Declaration

    Swift

    public func showEmptyView(text: String?, detail: String?, image: UIImage?, action: String?, block: ((Any) -> Void)?)
  • 显示空界面,指定文本、详细文本、图片、是否显示加载视图和动作按钮

    Declaration

    Swift

    public func showEmptyView(text: String?, detail: String?, image: UIImage?, loading: Bool, action: String?, block: ((Any) -> Void)?)
  • 显示空界面,指定文本、详细文本、图片、是否显示加载视图和最多两个动作按钮

    Declaration

    Swift

    public func showEmptyView(text: String?, detail: String?, image: UIImage?, loading: Bool, actions: [String]?, block: ((Int, Any) -> Void)?)
  • 隐藏空界面

    Declaration

    Swift

    public func hideEmptyView()

Available where Base: UIViewController

  • 设置空界面外间距,默认zero

    Declaration

    Swift

    public var emptyInsets: UIEdgeInsets { get set }
  • 是否显示空界面

    Declaration

    Swift

    public var hasEmptyView: Bool { get }
  • 显示空界面

    Declaration

    Swift

    public func showEmptyView()
  • 显示空界面加载视图

    Declaration

    Swift

    public func showEmptyLoading()
  • 显示空界面,指定文本和详细文本

    Declaration

    Swift

    public func showEmptyView(text: String?, detail: String? = nil)
  • 显示空界面,指定文本、详细文本和图片

    Declaration

    Swift

    public func showEmptyView(text: String?, detail: String?, image: UIImage?)
  • 显示空界面,指定文本、详细文本、图片和动作按钮

    Declaration

    Swift

    public func showEmptyView(text: String?, detail: String?, image: UIImage?, action: String?, block: ((Any) -> Void)?)
  • 显示空界面,指定文本、详细文本、图片、是否显示加载视图和动作按钮

    Declaration

    Swift

    public func showEmptyView(text: String?, detail: String?, image: UIImage?, loading: Bool, action: String?, block: ((Any) -> Void)?)
  • 显示空界面,指定文本、详细文本、图片、是否显示加载视图和最多两个动作按钮

    Declaration

    Swift

    public func showEmptyView(text: String?, detail: String?, image: UIImage?, loading: Bool, actions: [String]?, block: ((Int, Any) -> Void)?)
  • 隐藏空界面

    Declaration

    Swift

    public func hideEmptyView()

Available where Base: UIScrollView

  • 空界面代理,默认nil

    Declaration

    Swift

    public weak var emptyViewDelegate: EmptyViewDelegate? { get set }
  • 刷新空界面

    Declaration

    Swift

    public func reloadEmptyView()
  • 滚动视图自定义浮层,用于显示空界面等,兼容UITableView|UICollectionView

    Declaration

    Swift

    public var overlayView: UIView { get }
  • 是否显示自定义浮层

    Declaration

    Swift

    public var hasOverlayView: Bool { get }
  • 显示自定义浮层,默认不执行渐变动画,自动添加到滚动视图顶部、表格视图底部

    Declaration

    Swift

    public func showOverlayView(animated: Bool = false)
  • 隐藏自定义浮层,自动从滚动视图移除

    Declaration

    Swift

    public func hideOverlayView()

Available where Base: PHPhotoLibrary

  • 保存图片或视频到指定的相册

    无论用户保存到哪个自行创建的相册,系统都会在“相机胶卷”相册中同时保存这个图片。

    • 原因请参考 FWAssetManager 对象的保存图片和视频方法的注释。 无法通过该方法把图片保存到“智能相册”,“智能相册”只能由系统控制资源的增删。

    Declaration

    Swift

    public func addImage(toAlbum: CGImage, assetCollection: PHAssetCollection, orientation: UIImage.Orientation, completionHandler: ((Bool, Date?, Error?) -> Void)?)
  • Undocumented

    Declaration

    Swift

    public func addImage(toAlbum: URL, assetCollection: PHAssetCollection, completionHandler: ((Bool, Date?, Error?) -> Void)?)
  • Undocumented

    Declaration

    Swift

    public func addVideo(toAlbum: URL, assetCollection: PHAssetCollection, completionHandler: ((Bool, Date?, Error?) -> Void)?)
  • 根据 contentType 的值产生一个合适的 PHFetchOptions,并把内容以资源创建日期排序,创建日期较新的资源排在前面

    @param contentType 相册的内容类型

    @return 返回一个合适的 PHFetchOptions

    Declaration

    Swift

    public static func createFetchOptions(albumContentType: AlbumContentType) -> PHFetchOptions
  • 获取所有相册

    @param contentType 相册的内容类型,设定了内容类型后,所获取的相册中只包含对应类型的资源 @param showEmptyAlbum 是否显示空相册(经过 contentType 过滤后仍为空的相册) @param showSmartAlbum 是否显示“智能相册”

    @return 返回包含所有合适相册的数组

    Declaration

    Swift

    public static func fetchAllAlbums(albumContentType: AlbumContentType, showEmptyAlbum: Bool, showSmartAlbum: Bool) -> [PHAssetCollection]
  • 获取一个 PHAssetCollection 中创建日期最新的资源

    Declaration

    Swift

    public static func fetchLatestAsset(assetCollection: PHAssetCollection) -> PHAsset?
  • 图片选择器选择视频时临时文件存放目录,使用完成后需自行删除

    Declaration

    Swift

    public static var pickerControllerVideoCachePath: String { get }
  • 快速创建照片选择器(仅图片)

    @param selectionLimit 最大选择数量,iOS14以下只支持单选 @param allowsEditing 是否允许编辑,仅iOS14以下支持编辑 @param completion 完成回调,主线程。参数1为图片数组,2为结果数组,3为是否取消 @return 照片选择器

    Declaration

    Swift

    public static func pickerController(selectionLimit: Int, allowsEditing: Bool, completion: @escaping ([UIImage], [Any], Bool) -> Void) -> UIViewController?
  • 快速创建照片选择器,可自定义dismiss流程

    @param filterType 过滤类型,默认0同系统 @param selectionLimit 最大选择数量,iOS14以下只支持单选 @param allowsEditing 是否允许编辑,仅iOS14以下支持编辑 @param shouldDismiss 是否先关闭照片选择器再回调,如果先关闭则回调参数1为nil @param completion 完成回调,主线程。参数1为照片选择器,2为对象数组(UIImage|PHLivePhoto|NSURL),3位结果数组,4为是否取消 @return 照片选择器

    Declaration

    Swift

    public static func pickerController(filterType: ImagePickerFilterType, selectionLimit: Int, allowsEditing: Bool, shouldDismiss: Bool, completion: @escaping (UIViewController?, [Any], [Any], Bool) -> Void) -> UIViewController?
  • 快速创建单选照片选择器(仅图片),使用自定义裁剪控制器编辑

    @param cropController 自定义裁剪控制器句柄,nil时自动创建默认裁剪控制器 @param completion 完成回调,主线程。参数1为图片,2为结果信息,3为是否取消 @return 照片选择器

    Declaration

    Swift

    public static func pickerController(cropController: ((UIImage) -> ImageCropController)?, completion: @escaping (UIImage?, Any?, Bool) -> Void) -> UIViewController?

Available where Base: UIImage

Available where Base: UIViewController

  • 自定义图片选取插件,未设置时自动从插件池加载

    Declaration

    Swift

    public var imagePickerPlugin: ImagePickerPlugin? { get set }
  • 从Camera选取单张图片(简单版)

    Declaration

    Swift

    public func showImageCamera(allowsEditing: Bool, completion: @escaping (UIImage?, Bool) -> Void)

    Parameters

    allowsEditing

    是否允许编辑

    completion

    完成回调,主线程。参数1为图片,2为是否取消

  • 从Camera选取单张图片(详细版)

    Declaration

    Swift

    public func showImageCamera(filterType: ImagePickerFilterType, allowsEditing: Bool, customBlock: ((Any) -> Void)?, completion: @escaping (Any?, Any?, Bool) -> Void)

    Parameters

    filterType

    过滤类型,默认0同系统

    allowsEditing

    是否允许编辑

    customBlock

    自定义配置句柄,默认nil

    completion

    完成回调,主线程。参数1为对象(UIImage|PHLivePhoto|NSURL),2为结果信息,3为是否取消

  • 从图片库选取单张图片(简单版)

    Declaration

    Swift

    public func showImagePicker(allowsEditing: Bool, completion: @escaping (UIImage?, Bool) -> Void)

    Parameters

    allowsEditing

    是否允许编辑

    completion

    完成回调,主线程。参数1为图片,2为是否取消

  • 从图片库选取多张图片(简单版)

    Declaration

    Swift

    public func showImagePicker(selectionLimit: Int, allowsEditing: Bool, completion: @escaping ([UIImage], [Any], Bool) -> Void)

    Parameters

    selectionLimit

    最大选择数量

    allowsEditing

    是否允许编辑

    completion

    完成回调,主线程。参数1为图片数组,2为结果数组,3为是否取消

  • 从图片库选取多张图片(详细版)

    Declaration

    Swift

    public func showImagePicker(filterType: ImagePickerFilterType, selectionLimit: Int, allowsEditing: Bool, customBlock: ((Any) -> Void)?, completion: @escaping ([Any], [Any], Bool) -> Void)

    Parameters

    filterType

    过滤类型,默认0同系统

    selectionLimit

    最大选择数量

    allowsEditing

    是否允许编辑

    customBlock

    自定义配置句柄,默认nil

    completion

    完成回调,主线程。参数1为对象数组(UIImage|PHLivePhoto|NSURL),2位结果数组,3为是否取消

Available where Base: UIView

  • 从Camera选取单张图片(简单版)

    Declaration

    Swift

    public func showImageCamera(allowsEditing: Bool, completion: @escaping (UIImage?, Bool) -> Void)

    Parameters

    allowsEditing

    是否允许编辑

    completion

    完成回调,主线程。参数1为图片,2为是否取消

  • 从Camera选取单张图片(详细版)

    Declaration

    Swift

    public func showImageCamera(filterType: ImagePickerFilterType, allowsEditing: Bool, customBlock: ((Any) -> Void)?, completion: @escaping (Any?, Any?, Bool) -> Void)

    Parameters

    filterType

    过滤类型,默认0同系统

    allowsEditing

    是否允许编辑

    customBlock

    自定义配置句柄,默认nil

    completion

    完成回调,主线程。参数1为对象(UIImage|PHLivePhoto|NSURL),2为结果信息,3为是否取消

  • 从图片库选取单张图片(简单版)

    Declaration

    Swift

    public func showImagePicker(allowsEditing: Bool, completion: @escaping (UIImage?, Bool) -> Void)

    Parameters

    allowsEditing

    是否允许编辑

    completion

    完成回调,主线程。参数1为图片,2为是否取消

  • 从图片库选取多张图片(简单版)

    Declaration

    Swift

    public func showImagePicker(selectionLimit: Int, allowsEditing: Bool, completion: @escaping ([UIImage], [Any], Bool) -> Void)

    Parameters

    selectionLimit

    最大选择数量

    allowsEditing

    是否允许编辑

    completion

    完成回调,主线程。参数1为图片数组,2为结果数组,3为是否取消

  • 从图片库选取多张图片(详细版)

    Declaration

    Swift

    public func showImagePicker(filterType: ImagePickerFilterType, selectionLimit: Int, allowsEditing: Bool, customBlock: ((Any) -> Void)?, completion: @escaping ([Any], [Any], Bool) -> Void)

    Parameters

    filterType

    过滤类型,默认0同系统

    selectionLimit

    最大选择数量

    allowsEditing

    是否允许编辑

    customBlock

    自定义配置句柄,默认nil

    completion

    完成回调,主线程。参数1为对象数组(UIImage|PHLivePhoto|NSURL),2位结果数组,3为是否取消

Available where Base: UIImagePickerController

  • 快速创建单选照片选择器(仅图片),自动设置delegate

    @param sourceType 选择器类型 @param allowsEditing 是否允许编辑 @param completion 完成回调。参数1为图片,2为信息字典,3为是否取消 @return 照片选择器,不支持的返回nil

    Declaration

    Swift

    public static func pickerController(sourceType: UIImagePickerController.SourceType, allowsEditing: Bool, completion: @escaping (UIImage?, [AnyHashable : Any]?, Bool) -> Void) -> UIImagePickerController?
  • 快速创建单选照片选择器,可自定义dismiss流程,自动设置delegate

    @param sourceType 选择器类型 @param filterType 过滤类型,默认0同系统 @param allowsEditing 是否允许编辑 @param shouldDismiss 是否先关闭照片选择器再回调,如果先关闭则回调参数1为nil @param completion 完成回调。参数1为照片选择器,2为对象(UIImage|PHLivePhoto|NSURL),3为信息字典,4为是否取消 @return 照片选择器,不支持的返回nil

    Declaration

    Swift

    public static func pickerController(sourceType: UIImagePickerController.SourceType, filterType: ImagePickerFilterType, allowsEditing: Bool, shouldDismiss: Bool, completion: @escaping (UIImagePickerController?, Any?, [AnyHashable : Any]?, Bool) -> Void) -> UIImagePickerController?
  • 快速创建单选照片选择器,使用自定义裁剪控制器编辑

    @param sourceType 选择器类型 @param cropController 自定义裁剪控制器句柄,nil时自动创建默认裁剪控制器 @param completion 完成回调。参数1为图片,2为信息字典,3为是否取消 @return 照片选择器,不支持的返回nil

    Declaration

    Swift

    public static func pickerController(sourceType: UIImagePickerController.SourceType, cropController: ((UIImage) -> ImageCropController)?, completion: @escaping (UIImage?, [AnyHashable : Any]?, Bool) -> Void) -> UIImagePickerController?

Available where Base: PHPickerViewController

  • 快速创建多选照片选择器(仅图片),自动设置delegate

    @param selectionLimit 最大选择数量 @param completion 完成回调,主线程。参数1为图片数组,2为结果数组,3为是否取消 @return 照片选择器

    Declaration

    Swift

    public static func pickerController(selectionLimit: Int, completion: @escaping ([UIImage], [__PHPickerResult], Bool) -> Void) -> PHPickerViewController
  • 快速创建多选照片选择器,可自定义dismiss流程,自动设置delegate @note 当选择视频时,completion回调对象为NSURL临时文件路径,使用完毕后可手工删除或等待系统自动删除

    @param filterType 过滤类型,默认0同系统 @param selectionLimit 最大选择数量 @param shouldDismiss 是否先关闭照片选择器再回调,如果先关闭则回调参数1为nil @param completion 完成回调,主线程。参数1为照片选择器,2为对象数组(UIImage|PHLivePhoto|NSURL),3为结果数组,4为是否取消 @return 照片选择器

    Declaration

    Swift

    public static func pickerController(filterType: ImagePickerFilterType, selectionLimit: Int, shouldDismiss: Bool, completion: @escaping (PHPickerViewController?, [Any], [__PHPickerResult], Bool) -> Void) -> PHPickerViewController
  • 快速创建单选照片选择器(仅图片),使用自定义裁剪控制器编辑

    @param cropController 自定义裁剪控制器句柄,nil时自动创建默认裁剪控制器 @param completion 完成回调,主线程。参数1为图片,2为结果信息,3为是否取消 @return 照片选择器

    Declaration

    Swift

    public static func pickerController(cropController: ((UIImage) -> ImageCropController)?, completion: @escaping (UIImage?, __PHPickerResult?, Bool) -> Void) -> PHPickerViewController

Available where Base: UIImage

  • 根据名称从指定bundle加载UIImage,优先加载图片文件(无缓存),文件不存在时尝试系统imageNamed方式(有缓存)

    Declaration

    Swift

    public static func imageNamed(_ name: String, bundle: Bundle? = nil) -> UIImage?
  • 根据名称从指定bundle加载UIImage,优先加载图片文件(无缓存),文件不存在时尝试系统imageNamed方式(有缓存)。支持设置图片解码选项

    Declaration

    Swift

    public static func imageNamed(_ name: String, bundle: Bundle?, options: [ImageCoderOptions : Any]?) -> UIImage?
  • 从图片文件路径解码创建UIImage,自动识别scale,支持动图

    Declaration

    Swift

    public static func image(contentsOfFile: String) -> UIImage?
  • 从图片数据解码创建UIImage,默认scale为1,支持动图

    Declaration

    Swift

    public static func image(data: Data?, scale: CGFloat = 1) -> UIImage?
  • 从图片数据解码创建UIImage,指定scale,支持动图。支持设置图片解码选项

    Declaration

    Swift

    public static func image(data: Data?, scale: CGFloat, options: [ImageCoderOptions : Any]?) -> UIImage?
  • 从UIImage编码创建图片数据,支持动图。支持设置图片编码选项

    Declaration

    Swift

    public static func data(image: UIImage?, options: [ImageCoderOptions : Any]? = nil) -> Data?
  • 下载网络图片并返回下载凭据

    Declaration

    Swift

    @discardableResult
    public static func downloadImage(_ url: Any?, completion: @escaping (UIImage?, Error?) -> Void, progress: ((Double) -> Void)? = nil) -> Any?
  • 下载网络图片并返回下载凭据,指定option

    Declaration

    Swift

    @discardableResult
    public static func downloadImage(_ url: Any?, options: WebImageOptions, context: [ImageCoderOptions : Any]?, completion: @escaping (UIImage?, Error?) -> Void, progress: ((Double) -> Void)? = nil) -> Any?
  • 指定下载凭据取消网络图片下载

    Declaration

    Swift

    public static func cancelImageDownload(_ receipt: Any?)

Available where Base: UIImageView

  • 自定义图片插件,未设置时自动从插件池加载

    Declaration

    Swift

    public var imagePlugin: ImagePlugin? { get set }
  • 当前正在加载的网络图片URL

    Declaration

    Swift

    public var imageURL: URL? { get }
  • 加载网络图片,支持占位,优先加载插件,默认使用框架网络库

    Declaration

    Swift

    public func setImage(url: Any?, placeholderImage: UIImage? = nil)
  • 加载网络图片,支持占位和回调,优先加载插件,默认使用框架网络库

    Declaration

    Swift

    public func setImage(url: Any?, placeholderImage: UIImage?, completion: ((UIImage?, Error?) -> Void)?)
  • 加载网络图片,支持占位、选项、回调和进度,优先加载插件,默认使用框架网络库

    Declaration

    Swift

    public func setImage(url: Any?, placeholderImage: UIImage?, options: WebImageOptions, context: [ImageCoderOptions : Any]? = nil, completion: ((UIImage?, Error?) -> Void)? = nil, progress: ((Double) -> Void)? = nil)
  • 取消加载网络图片请求

    Declaration

    Swift

    public func cancelImageRequest()
  • 创建动画ImageView视图,优先加载插件,默认UIImageView

    Declaration

    Swift

    public static func animatedImageView() -> UIImageView

Available where Base: UIViewController

  • 自定义图片预览插件,未设置时自动从插件池加载

    Declaration

    Swift

    public var imagePreviewPlugin: ImagePreviewPlugin? { get set }
  • 显示图片预览(简单版)

    Declaration

    Swift

    public func showImagePreview(imageURLs: [Any], imageInfos: [Any]?, currentIndex: Int, sourceView: ((Int) -> Any?)? = nil)

    Parameters

    imageURLs

    预览图片列表,支持NSString|UIImage|PHLivePhoto|AVPlayerItem类型

    imageInfos

    自定义图片信息数组

    currentIndex

    当前索引,默认0

    sourceView

    来源视图,可选,支持UIView|NSValue.CGRect,默认nil

  • 显示图片预览(详细版)

    Declaration

    Swift

    public func showImagePreview(imageURLs: [Any], imageInfos: [Any]?, currentIndex: Int, sourceView: ((Int) -> Any?)?, placeholderImage: ((Int) -> UIImage?)?, renderBlock: ((UIView, Int) -> Void)?, customBlock: ((Any) -> Void)? = nil)

    Parameters

    imageURLs

    预览图片列表,支持NSString|UIImage|PHLivePhoto|AVPlayerItem类型

    imageInfos

    自定义图片信息数组

    currentIndex

    当前索引,默认0

    sourceView

    来源视图句柄,支持UIView|NSValue.CGRect,默认nil

    placeholderImage

    占位图或缩略图句柄,默认nil

    renderBlock

    自定义渲染句柄,默认nil

    customBlock

    自定义句柄,默认nil

Available where Base: UIView

  • 将要设置的frame按照view的anchorPoint(.5, .5)处理后再设置,而系统默认按照(0, 0)方式计算

    Declaration

    Swift

    public var frameApplyTransform: CGRect { get set }
  • 显示图片预览(简单版)

    Declaration

    Swift

    public func showImagePreview(imageURLs: [Any], imageInfos: [Any]?, currentIndex: Int, sourceView: ((Int) -> Any?)? = nil)

    Parameters

    imageURLs

    预览图片列表,支持NSString|UIImage|PHLivePhoto|AVPlayerItem类型

    imageInfos

    自定义图片信息数组

    currentIndex

    当前索引,默认0

    sourceView

    来源视图,可选,支持UIView|NSValue.CGRect,默认nil

  • 显示图片预览(详细版)

    Declaration

    Swift

    public func showImagePreview(imageURLs: [Any], imageInfos: [Any]?, currentIndex: Int, sourceView: ((Int) -> Any?)?, placeholderImage: ((Int) -> UIImage?)?, renderBlock: ((UIView, Int) -> Void)?, customBlock: ((Any) -> Void)? = nil)

    Parameters

    imageURLs

    预览图片列表,支持NSString|UIImage|PHLivePhoto|AVPlayerItem类型

    imageInfos

    自定义图片信息数组

    currentIndex

    当前索引,默认0

    sourceView

    来源视图句柄,支持UIView|NSValue.CGRect,默认nil

    placeholderImage

    占位图或缩略图句柄,默认nil

    renderBlock

    自定义渲染句柄,默认nil

    customBlock

    自定义句柄,默认nil

Available where Base: UIScrollView

  • 自定义刷新插件,未设置时自动从插件池加载

    Declaration

    Swift

    public var refreshPlugin: RefreshPlugin? { get set }

Refreshing

  • 是否正在刷新中

    Declaration

    Swift

    public var isRefreshing: Bool { get }
  • 是否显示刷新组件

    Declaration

    Swift

    public var shouldRefreshing: Bool { get set }
  • 配置下拉刷新句柄

    Declaration

    Swift

    public func setRefreshing(block: @escaping () -> Void)
  • 配置下拉刷新事件

    Declaration

    Swift

    public func setRefreshing(target: Any, action: Selector)
  • 开始下拉刷新

    Declaration

    Swift

    public func beginRefreshing()
  • 结束下拉刷新

    Declaration

    Swift

    public func endRefreshing()

Loading

  • 是否正在追加中

    Declaration

    Swift

    public var isLoading: Bool { get }
  • 是否显示追加组件

    Declaration

    Swift

    public var shouldLoading: Bool { get set }
  • 是否已加载完成,不能继续追加

    Declaration

    Swift

    public var loadingFinished: Bool { get set }
  • 配置上拉追加句柄

    Declaration

    Swift

    public func setLoading(block: @escaping () -> Void)
  • 配置上拉追加事件

    Declaration

    Swift

    public func setLoading(target: Any, action: Selector)
  • 开始上拉追加

    Declaration

    Swift

    public func beginLoading()
  • 结束上拉追加

    Declaration

    Swift

    public func endLoading()

Available where Base: UIScrollView

Available where Base: UIView

  • 自定义吐司插件,未设置时自动从插件池加载

    Declaration

    Swift

    public var toastPlugin: ToastPlugin? { get set }
  • 设置吐司外间距,默认zero

    Declaration

    Swift

    public var toastInsets: UIEdgeInsets { get set }
  • 显示加载吐司,需手工隐藏,支持String和AttributedString

    Declaration

    Swift

    public func showLoading(text: Any? = nil)
  • 显示加载吐司,默认需手工隐藏,指定cancelBlock时会自动隐藏并调用之,支持String和AttributedString

    Declaration

    Swift

    public func showLoading(text: Any?, cancel: (() -> Void)?)
  • 隐藏加载吐司

    Declaration

    Swift

    public func hideLoading()
  • 是否正在显示加载吐司

    Declaration

    Swift

    public var isShowingLoading: Bool { get }
  • 显示进度条吐司,需手工隐藏,支持String和AttributedString

    Declaration

    Swift

    public func showProgress(_ progress: CGFloat, text: Any? = nil)
  • 显示进度条吐司,默认需手工隐藏,指定cancelBlock时会自动隐藏并调用之,支持String和AttributedString

    Declaration

    Swift

    public func showProgress(_ progress: CGFloat, text: Any?, cancel: (() -> Void)?)
  • 隐藏进度条吐司

    Declaration

    Swift

    public func hideProgress()
  • 是否正在显示进度条吐司

    Declaration

    Swift

    public var isShowingProgress: Bool { get }
  • 显示指定样式消息吐司,自动隐藏,支持String和AttributedString

    Declaration

    Swift

    public func showMessage(text: Any?, style: ToastStyle = .default)
  • 显示指定样式消息吐司,自动隐藏,自动隐藏完成后回调,支持String和AttributedString

    Declaration

    Swift

    public func showMessage(text: Any?, style: ToastStyle, completion: (() -> Void)?)
  • 显示指定样式消息吐司,可设置自动隐藏和允许交互,自动隐藏完成后回调,支持String和AttributedString

    Declaration

    Swift

    public func showMessage(text: Any?, style: ToastStyle, autoHide: Bool, interactive: Bool, completion: (() -> Void)?)
  • 隐藏消息吐司

    Declaration

    Swift

    public func hideMessage()
  • 是否正在显示消息吐司

    Declaration

    Swift

    public var isShowingMessage: Bool { get }

Available where Base: UIViewController

  • 设置吐司是否显示在window上,默认NO,显示到view上

    Declaration

    Swift

    public var toastInWindow: Bool { get set }
  • 设置吐司外间距,默认zero

    Declaration

    Swift

    public var toastInsets: UIEdgeInsets { get set }
  • 显示加载吐司,需手工隐藏,支持String和AttributedString

    Declaration

    Swift

    public func showLoading(text: Any? = nil)
  • 显示加载吐司,默认需手工隐藏,指定cancelBlock时会自动隐藏并调用之,支持String和AttributedString

    Declaration

    Swift

    public func showLoading(text: Any?, cancel: (() -> Void)?)
  • 隐藏加载吐司

    Declaration

    Swift

    public func hideLoading()
  • Undocumented

    Declaration

    Swift

    public var isShowingLoading: Bool { get }
  • 显示进度条吐司,需手工隐藏,支持String和AttributedString

    Declaration

    Swift

    public func showProgress(_ progress: CGFloat, text: Any? = nil)
  • 显示进度条吐司,默认需手工隐藏,指定cancelBlock时会自动隐藏并调用之,支持String和AttributedString

    Declaration

    Swift

    public func showProgress(_ progress: CGFloat, text: Any?, cancel: (() -> Void)?)
  • 隐藏进度条吐司

    Declaration

    Swift

    public func hideProgress()
  • 是否正在显示进度条吐司

    Declaration

    Swift

    public var isShowingProgress: Bool { get }
  • 显示指定样式消息吐司,自动隐藏,支持String和AttributedString

    Declaration

    Swift

    public func showMessage(text: Any?, style: ToastStyle = .default)
  • 显示指定样式消息吐司,自动隐藏,自动隐藏完成后回调,支持String和AttributedString

    Declaration

    Swift

    public func showMessage(text: Any?, style: ToastStyle, completion: (() -> Void)?)
  • 显示指定样式消息吐司,可设置自动隐藏和允许交互,自动隐藏完成后回调,支持String和AttributedString

    Declaration

    Swift

    public func showMessage(text: Any?, style: ToastStyle, autoHide: Bool, interactive: Bool, completion: (() -> Void)?)
  • 隐藏消息吐司

    Declaration

    Swift

    public func hideMessage()
  • 是否正在显示消息吐司

    Declaration

    Swift

    public var isShowingMessage: Bool { get }

Available where Base: UIWindow

  • 设置吐司外间距,默认zero

    Declaration

    Swift

    public static var toastInsets: UIEdgeInsets { get set }
  • 显示加载吐司,需手工隐藏,支持String和AttributedString

    Declaration

    Swift

    public static func showLoading(text: Any? = nil)
  • 显示加载吐司,默认需手工隐藏,指定cancelBlock时会自动隐藏并调用之,支持String和AttributedString

    Declaration

    Swift

    public static func showLoading(text: Any?, cancel: (() -> Void)?)
  • 隐藏加载吐司

    Declaration

    Swift

    public static func hideLoading()
  • Undocumented

    Declaration

    Swift

    public static var isShowingLoading: Bool { get }
  • 显示进度条吐司,需手工隐藏,支持String和AttributedString

    Declaration

    Swift

    public static func showProgress(_ progress: CGFloat, text: Any? = nil)
  • 显示进度条吐司,默认需手工隐藏,指定cancelBlock时会自动隐藏并调用之,支持String和AttributedString

    Declaration

    Swift

    public static func showProgress(_ progress: CGFloat, text: Any?, cancel: (() -> Void)?)
  • 隐藏进度条吐司

    Declaration

    Swift

    public static func hideProgress()
  • 是否正在显示进度条吐司

    Declaration

    Swift

    public static var isShowingProgress: Bool { get }
  • 显示指定样式消息吐司,自动隐藏,支持String和AttributedString

    Declaration

    Swift

    public static func showMessage(text: Any?, style: ToastStyle = .default)
  • 显示指定样式消息吐司,自动隐藏,自动隐藏完成后回调,支持String和AttributedString

    Declaration

    Swift

    public static func showMessage(text: Any?, style: ToastStyle, completion: (() -> Void)?)
  • 显示指定样式消息吐司,可设置自动隐藏和允许交互,自动隐藏完成后回调,支持String和AttributedString

    Declaration

    Swift

    public static func showMessage(text: Any?, style: ToastStyle, autoHide: Bool, interactive: Bool, completion: (() -> Void)?)
  • 隐藏消息吐司

    Declaration

    Swift

    public static func hideMessage()
  • 是否正在显示消息吐司

    Declaration

    Swift

    public static var isShowingMessage: Bool { get }

Available where Base: UIView

  • 自定义视图插件,未设置时自动从插件池加载

    Declaration

    Swift

    public var viewPlugin: ViewPlugin? { get set }
  • 统一进度视图工厂方法

    Declaration

    Swift

    public func progressView(style: ProgressViewStyle) -> UIView & ProgressViewPlugin
  • 统一指示器视图工厂方法

    Declaration

    Swift

    public func indicatorView(style: IndicatorViewStyle) -> UIView & IndicatorViewPlugin
  • 统一进度视图工厂方法

    Declaration

    Swift

    public static func progressView(style: ProgressViewStyle) -> UIView & ProgressViewPlugin
  • 统一指示器视图工厂方法

    Declaration

    Swift

    public static func indicatorView(style: IndicatorViewStyle) -> UIView & IndicatorViewPlugin

Available where Base: UIActivityIndicatorView

  • 快速创建指示器,可指定颜色,默认白色

    Declaration

    Swift

    public static func indicatorView(color: UIColor?) -> UIActivityIndicatorView

Available where Base: UIImage

  • 图片循环次数,静态图片始终是0,动态图片0代表无限循环

    Declaration

    Swift

    public var imageLoopCount: UInt { get set }
  • 是否是动图,内部检查images数组

    Declaration

    Swift

    public var isAnimated: Bool { get }
  • 是否是向量图,内部检查isSymbolImage属性,iOS11+支持PDF,iOS13+支持SVG

    Declaration

    Swift

    public var isVector: Bool { get }
  • 获取图片原始数据格式,未指定时尝试从CGImage获取,获取失败返回FWImageFormatUndefined

    Declaration

    Swift

    public var imageFormat: ImageFormat { get set }

Available where Base == Data

  • 获取图片数据的格式,未知格式返回FWImageFormatUndefined

    Declaration

    Swift

    public static func imageFormat(for imageData: Data?) -> ImageFormat
  • 图片格式转化为UTType,未知格式返回kUTTypeImage

    Declaration

    Swift

    public static func utType(from imageFormat: ImageFormat) -> CFString
  • UTType转化为图片格式,未知格式返回FWImageFormatUndefined

    Declaration

    Swift

    public static func imageFormat(form utType: CFString) -> ImageFormat
  • 图片格式转化为mimeType,未知格式返回application/octet-stream

    Declaration

    Swift

    public static func mimeType(form imageFormat: ImageFormat) -> String
  • 文件后缀转化为mimeType,未知后缀返回application/octet-stream

    Declaration

    Swift

    public static func mimeType(form ext: String) -> String
  • 图片数据编码为base64字符串,可直接用于H5显示等,字符串格式:data:image/png;base64,数据

    Declaration

    Swift

    public static func base64String(for imageData: Data?) -> String?

Available where Base: NSMutableAttributedString

  • Undocumented

    Declaration

    Swift

    public var textColor: UIColor? { get set }
  • Undocumented

    Declaration

    Swift

    public func setTextColor(_ color: UIColor, range: NSRange)
  • Undocumented

    Declaration

    Swift

    public var font: UIFont? { get set }
  • Undocumented

    Declaration

    Swift

    public func setFont(_ font: UIFont, range: NSRange)
  • Undocumented

    Declaration

    Swift

    public func setUnderlineStyle(_ style: CTUnderlineStyle, modifier: CTUnderlineStyleModifiers)
  • Undocumented

    Declaration

    Swift

    public func setUnderlineStyle(_ style: CTUnderlineStyle, modifier: CTUnderlineStyleModifiers, range: NSRange)

Available where Base: UIView

  • 显示右上角提醒灯,上右偏移指定距离

    Declaration

    Swift

    public func showBadgeView(_ badgeView: BadgeView, badgeValue: String? = nil)
  • 隐藏提醒灯

    Declaration

    Swift

    public func hideBadgeView()

Available where Base: UIBarItem

  • 获取UIBarItem(UIBarButtonItem、UITabBarItem)内部的view,通常对于navigationItem和tabBarItem而言,需要在设置为item后并且在bar可见时(例如 viewDidAppear:及之后)获取fwView才有值

    Declaration

    Swift

    public weak var view: UIView? { get }
  • 当item内的view生成后就会调用一次这个block,仅对UIBarButtonItem、UITabBarItem有效

    Declaration

    Swift

    public var viewLoadedBlock: ((UIBarItem, UIView) -> Void)? { get set }

Available where Base: UIBarButtonItem

  • 显示右上角提醒灯,上右偏移指定距离

    Declaration

    Swift

    public func showBadgeView(_ badgeView: BadgeView, badgeValue: String? = nil)
  • 隐藏提醒灯

    Declaration

    Swift

    public func hideBadgeView()

Available where Base: UITabBarItem

  • 获取一个UITabBarItem内显示图标的UIImageView,如果找不到则返回nil

    Declaration

    Swift

    public weak var imageView: UIImageView? { get }
  • 显示右上角提醒灯,上右偏移指定距离

    Declaration

    Swift

    public func showBadgeView(_ badgeView: BadgeView, badgeValue: String? = nil)
  • 隐藏提醒灯

    Declaration

    Swift

    public func hideBadgeView()

Available where Base: CALayer

Available where Base: UICollectionViewFlowLayout

  • 初始化布局section配置,在prepareLayout调用即可

    Declaration

    Swift

    public func sectionConfigPrepareLayout()
  • 获取布局section属性,在layoutAttributesForElementsInRect:调用并添加即可

    Declaration

    Swift

    public func sectionConfigLayoutAttributes(forElementsIn rect: CGRect) -> [UICollectionViewLayoutAttributes]

Available where Base: UIView

  • 抽屉拖拽视图,绑定抽屉拖拽效果后才存在

    Declaration

    Swift

    public var drawerView: DrawerView? { get set }
  • 设置抽屉拖拽效果。如果view为滚动视图,自动处理与滚动视图pan手势冲突的问题

    @param direction 拖拽方向,如向上拖动视图时为Up,默认向上 @param positions 抽屉位置,至少两级,相对于view父视图的originY位置 @param kickbackHeight 回弹高度,拖拽小于该高度执行回弹 @param callback 抽屉视图位移回调,参数为相对父视图的origin位置和是否拖拽完成的标记 @return 抽屉拖拽视图

    Declaration

    Swift

    @discardableResult
    public func drawerView(_ direction: UISwipeGestureRecognizer.Direction, positions: [NSNumber], kickbackHeight: CGFloat, callback: ((CGFloat, Bool) -> Void)? = nil) -> DrawerView

Available where Base: UIScrollView

  • 外部滚动视图是否位于顶部固定位置,在顶部时不能滚动

    Declaration

    Swift

    public var drawerSuperviewFixed: Bool { get set }
  • 外部滚动视图scrollViewDidScroll调用,参数为固定的位置

    Declaration

    Swift

    public func drawerSuperviewDidScroll(_ position: CGFloat)
  • 内嵌滚动视图scrollViewDidScroll调用,参数为外部滚动视图

    Declaration

    Swift

    public func drawerSubviewDidScroll(_ superview: UIScrollView)

Available where Base: UIView

Available where Base: UIViewController

Available where Base: UIView

  • 绑定统计点击事件,触发管理器。view为添加的Tap手势(需先添加手势),control为TouchUpInside|ValueChanged,tableView|collectionView为Select(需先设置delegate)

    Declaration

    Swift

    public var statisticalClick: StatisticalObject? { get set }
  • 绑定统计点击事件,仅触发回调。view为添加的Tap手势(需先添加手势),control为TouchUpInside|ValueChanged,tableView|collectionView为Select(需先设置delegate)

    Declaration

    Swift

    public var statisticalClickBlock: StatisticalBlock? { get set }
  • 手工触发统计点击事件,更新点击次数,列表可指定cell和位置,可重复触发

    Declaration

    Swift

    public func statisticalTriggerClick(_ cell: UIView?, indexPath: IndexPath?)
  • 绑定统计曝光事件,触发管理器。如果对象发生变化(indexPath|name|object),也会触发

    Declaration

    Swift

    public var statisticalExposure: StatisticalObject? { get set }
  • 绑定统计曝光事件,仅触发回调

    Declaration

    Swift

    public var statisticalExposureBlock: StatisticalBlock? { get set }
  • 手工触发统计曝光事件,更新曝光次数和时长,列表可指定cell和位置,duration为单次曝光时长(0表示开始),可重复触发

    Declaration

    Swift

    public func statisticalTriggerExposure(_ cell: UIView?, indexPath: IndexPath?, duration: TimeInterval)

Available where Base: Bundle

  • 自定义GoogleMaps反解析地址结果语言,为nil时不指定

    Declaration

    Swift

    public static func setGoogleMapsLanguage(_ language: String?)
  • 自定义GooglePlaces查询地址结果语言,为nil时不指定

    Declaration

    Swift

    public static func setGooglePlacesLanguage(_ language: String?)

Encrypt

  • 利用AES加密数据

    Declaration

    Swift

    public func aesEncrypt(key: String, iv: Data) -> Data?
  • 利用AES解密数据

    Declaration

    Swift

    public func aesDecrypt(key: String, iv: Data) -> Data?
  • 利用3DES加密数据

    Declaration

    Swift

    public func des3Encrypt(key: String, iv: Data) -> Data?
  • 利用3DES解密数据

    Declaration

    Swift

    public func des3Decrypt(key: String, iv: Data) -> Data?

RSA

  • RSA公钥加密,数据传输安全,使用默认标签,执行base64编码

    Declaration

    Swift

    public func rsaEncrypt(publicKey: String) -> Data?
  • RSA公钥加密,数据传输安全,可自定义标签,指定base64编码

    Declaration

    Swift

    public func rsaEncrypt(publicKey: String, tag: String, base64Encode: Bool) -> Data?
  • RSA私钥解密,数据传输安全,使用默认标签,执行base64解密

    Declaration

    Swift

    public func rsaDecrypt(privateKey: String) -> Data?
  • RSA私钥解密,数据传输安全,可自定义标签,指定base64解码

    Declaration

    Swift

    public func rsaDecrypt(privateKey: String, tag: String, base64Decode: Bool) -> Data?
  • RSA私钥加签,防篡改防否认,使用默认标签,执行base64编码

    Declaration

    Swift

    public func rsaSign(privateKey: String) -> Data?
  • RSA私钥加签,防篡改防否认,可自定义标签,指定base64编码

    Declaration

    Swift

    public func rsaSign(privateKey: String, tag: String, base64Encode: Bool) -> Data?
  • RSA公钥验签,防篡改防否认,使用默认标签,执行base64解密

    Declaration

    Swift

    public func rsaVerify(publicKey: String) -> Data?
  • RSA公钥验签,防篡改防否认,可自定义标签,指定base64解码

    Declaration

    Swift

    public func rsaVerify(publicKey: String, tag: String, base64Decode: Bool) -> Data?

Convert

  • 计算两个时间差,并格式化为友好的时间字符串(类似微博) <10分钟:刚刚 <60分钟:n分钟前 <24小时:n小时前 <7天:n天前 <365天:n月/n日 >=365天:n年/n月

    @return 字符串

    Declaration

    Swift

    public func string(sinceDate: Date) -> String
  • 转化为UTC时间戳

    @return UTC时间戳

    Declaration

    Swift

    public var timestampValue: TimeInterval { get }

TimeZone

  • 转换为当前时区时间

    Declaration

    Swift

    public var localTimeZoneDate: Date { get }
  • 转换为UTC时区时间

    Declaration

    Swift

    public var utcTimeZoneDate: Date { get }
  • 转换为指定时区时间

    Declaration

    Swift

    public func date(timeZone: TimeZone?) -> Date

Calendar

  • 获取日历单元值,如年、月、日等

    Declaration

    Swift

    public func calendarUnit(_ unit: NSCalendar.Unit) -> Int
  • 是否是闰年

    Declaration

    Swift

    public var isLeapYear: Bool { get }
  • 是否是同一天

    Declaration

    Swift

    public func isSameDay(_ date: Date) -> Bool
  • 添加指定日期,如year:1|month:-1|day:1等

    Declaration

    Swift

    public func date(byAdding: DateComponents) -> Date?
  • 与指定日期相隔天数

    Declaration

    Swift

    public func days(from date: Date) -> Int
  • 与指定日期相隔秒数。分钟数/60,小时数/3600

    Declaration

    Swift

    public func seconds(from date: Date) -> TimeInterval
  • 系统运行时间

    Declaration

    Swift

    public static var systemUptime: TimeInterval { get }
  • 系统启动时间

    Declaration

    Swift

    public static var systemBoottime: TimeInterval { get }
  • 从时间戳初始化日期

    Declaration

    Swift

    public static func date(timestamp: TimeInterval) -> Date

Available where Base: FileManager

  • 搜索路径

    Declaration

    Swift

    public static func pathSearch(_ directory: FileManager.SearchPathDirectory) -> String

    Parameters

    directory

    搜索目录

    Return Value

    目标路径

  • 沙盒路径,常量

    Declaration

    Swift

    public static var pathHome: String { get }
  • 文档路径,iTunes会同步备份

    Declaration

    Swift

    public static var pathDocument: String { get }
  • 缓存路径,系统不会删除,iTunes会删除

    Declaration

    Swift

    public static var pathCaches: String { get }
  • Library路径

    Declaration

    Swift

    public static var pathLibrary: String { get }
  • 配置路径,配置文件保存位置

    Declaration

    Swift

    public static var pathPreference: String { get }
  • 临时路径,App退出后可能会删除

    Declaration

    Swift

    public static var pathTmp: String { get }
  • bundle路径,不可写

    Declaration

    Swift

    public static var pathBundle: String { get }
  • 资源路径,不可写

    Declaration

    Swift

    public static var pathResource: String { get }
  • 绝对路径缩短为波浪线路径

    Declaration

    Swift

    public static func abbreviateTildePath(_ path: String) -> String
  • 波浪线路径展开为绝对路径

    Declaration

    Swift

    public static func expandTildePath(_ path: String) -> String

Size

  • 获取目录大小,单位:B

    Declaration

    Swift

    public static func folderSize(_ folderPath: String) -> UInt64
  • 获取磁盘可用空间,单位:MB

    Declaration

    Swift

    public static var availableDiskSize: Double { get }

Addition

  • 禁止iCloud备份路径

    Declaration

    Swift

    @discardableResult
    public static func skipBackup(_ path: String) -> Bool

Html

  • html字符串转换为NSAttributedString对象,可设置默认系统字体和颜色(附加CSS方式)

    Declaration

    Swift

    public static func attributedString(htmlString: String, defaultAttributes: [NSAttributedString.Key : Any]?) -> Base?
  • html字符串转换为NSAttributedString主题对象,可设置默认系统字体和动态颜色,详见FWThemeObject

    Declaration

    Swift

    public static func themeObject(htmlString: String, defaultAttributes: [NSAttributedString.Key : Any]?) -> ThemeObject<NSAttributedString>
  • 获取颜色对应CSS字符串(rgb|rgba格式)

    Declaration

    Swift

    public static func cssString(color: UIColor) -> String
  • 获取系统字体对应CSS字符串(family|style|weight|size)

    Declaration

    Swift

    public static func cssString(font: UIFont) -> String

Option

  • 快速创建NSAttributedString,自定义选项

    Declaration

    Swift

    public static func attributedString(_ string: String, option: AttributedOption?) -> Base

Available where Base: NSNumber

  • 转换为CGFloat

    Declaration

    Swift

    public var CGFloatValue: CGFloat { get }
  • 四舍五入,去掉末尾0,最多digit位,小数分隔符为.,分组分隔符为空,示例:12345.6789 => 12345.68

    Declaration

    Swift

    public func roundString(_ digit: Int) -> String
  • 取上整,去掉末尾0,最多digit位,小数分隔符为.,分组分隔符为空,示例:12345.6789 => 12345.68

    Declaration

    Swift

    public func ceilString(_ digit: Int) -> String
  • 取下整,去掉末尾0,最多digit位,小数分隔符为.,分组分隔符为空,示例:12345.6789 => 12345.67

    Declaration

    Swift

    public func floorString(_ digit: Int) -> String
  • 四舍五入,去掉末尾0,最多digit位,示例:12345.6789 => 12345.68

    Declaration

    Swift

    public func roundNumber(_ digit: UInt) -> NSNumber
  • 取上整,去掉末尾0,最多digit位,示例:12345.6789 => 12345.68

    Declaration

    Swift

    public func ceilNumber(_ digit: UInt) -> NSNumber
  • 取下整,去掉末尾0,最多digit位,示例:12345.6789 => 12345.67

    Declaration

    Swift

    public func floorNumber(_ digit: UInt) -> NSNumber

Archive

  • 使用NSKeyedArchiver和NSKeyedUnarchiver深拷对象

    @return 出错返回nil

    Declaration

    Swift

    public func archiveCopy() -> Any?

Block

  • 延迟delay秒后主线程执行,返回可取消的block,对象范围

    Declaration

    Swift

    @discardableResult
    public func performBlock(
        _ block: @escaping (Any) -> Void,
        afterDelay delay: TimeInterval
    ) -> Any
  • 延迟delay秒后后台线程执行,返回可取消的block,对象范围

    Declaration

    Swift

    @discardableResult
    public func performBlock(
        inBackground block: @escaping (Any) -> Void,
        afterDelay delay: TimeInterval
    ) -> Any
  • 延迟delay秒后指定线程执行,返回可取消的block,对象范围

    Declaration

    Swift

    @discardableResult
    public func performBlock(
        _ block: @escaping (Any) -> Void,
        on: DispatchQueue,
        afterDelay delay: TimeInterval
    ) -> Any
  • 同步方式执行异步block,阻塞当前线程(信号量),异步block必须调用completionHandler,全局范围

    Declaration

    Swift

    public func syncPerform(
        asyncBlock: @escaping (@escaping () -> Void) -> Void
    )
  • 同一个identifier仅执行一次block,对象范围

    Declaration

    Swift

    public func performOnce(
        _ identifier: String,
        with block: @escaping () -> Void
    )
  • 重试方式执行异步block,直至成功或者次数为0或者超时,完成后回调completion。block必须调用completionHandler,参数示例:重试4次|超时8秒|延迟2秒

    Declaration

    Swift

    public func performBlock(
        _ block: @escaping (@escaping (Bool, Any?) -> Void) -> Void,
        completion: @escaping (Bool, Any?) -> Void,
        retryCount: UInt,
        timeoutInterval: TimeInterval,
        delayInterval: TimeInterval
    )
  • 延迟delay秒后主线程执行,返回可取消的block,全局范围

    Declaration

    Swift

    @discardableResult
    public static func performBlock(
        _ block: @escaping () -> Void,
        afterDelay delay: TimeInterval
    ) -> Any
  • 延迟delay秒后后台线程执行,返回可取消的block,全局范围

    Declaration

    Swift

    @discardableResult
    public static func performBlock(
        inBackground block: @escaping () -> Void,
        afterDelay delay: TimeInterval
    ) -> Any
  • 延迟delay秒后指定线程执行,返回可取消的block,全局范围

    Declaration

    Swift

    @discardableResult
    public static func performBlock(
        _ block: @escaping () -> Void,
        on: DispatchQueue,
        afterDelay delay: TimeInterval
    ) -> Any
  • 取消指定延迟block,全局范围

    Declaration

    Swift

    public static func cancelBlock(_ block: Any)
  • 同步方式执行异步block,阻塞当前线程(信号量),异步block必须调用completionHandler,全局范围

    Declaration

    Swift

    public static func syncPerform(
        asyncBlock: @escaping (@escaping () -> Void) -> Void
    )
  • 同一个identifier仅执行一次block,全局范围

    Declaration

    Swift

    public static func performOnce(
        _ identifier: String,
        with block: @escaping () -> Void
    )
  • 重试方式执行异步block,直至成功或者次数为0或者超时,完成后回调completion。block必须调用completionHandler,参数示例:重试4次|超时8秒|延迟2秒

    Declaration

    Swift

    public static func performBlock(
        _ block: @escaping (@escaping (Bool, Any?) -> Void) -> Void,
        completion: @escaping (Bool, Any?) -> Void,
        retryCount: UInt,
        timeoutInterval: TimeInterval,
        delayInterval: TimeInterval
    )
  • 执行轮询block任务,返回任务Id可取消

    Declaration

    Swift

    @discardableResult
    public static func performTask(_ task: @escaping () -> Void, start: TimeInterval, interval: TimeInterval, repeats: Bool, async: Bool) -> String
  • 指定任务Id取消轮询任务

    Declaration

    Swift

    public static func cancelTask(_ taskId: String)

Debug

  • 获取当前对象的所有 @property、方法,父类的方法也会分别列出

    Declaration

    Swift

    public var methodList: String { get }
  • 获取当前对象的所有 @property、方法,不包含父类的

    Declaration

    Swift

    public var shortMethodList: String { get }
  • 当前对象的所有 Ivar 变量

    Declaration

    Swift

    public var ivarList: String { get }

Pinyin

  • 中文转拼音并进行比较

    @param string 中文字符串

    Declaration

    Swift

    public func pinyinCompare(_ string: String) -> ComparisonResult

Regex

  • 安全截取字符串。解决末尾半个Emoji问题(半个Emoji调UTF8String为NULL,导致MD5签名等失败)

    @param index 目标索引

    Declaration

    Swift

    public func emojiSubstring(_ index: UInt) -> String
  • 正则搜索子串

    @param regex 正则表达式

    Declaration

    Swift

    public func regexSubstring(_ regex: String) -> String?
  • 正则替换字符串

    @param regex 正则表达式 @param string 替换模板,如"头部$1中部$2尾部“

    @return 替换后的字符串

    Declaration

    Swift

    public func regexReplace(_ regex: String, string: String) -> String
  • 正则匹配回调

    @param regex 正则表达式 @param block 回调句柄。range从大至小,方便replace

    Declaration

    Swift

    public func regexMatches(_ regex: String, block: @escaping (NSRange) -> Void)

Html

  • 转义Html,如"a<“转义为"a<”

    Declaration

    Swift

    public var escapeHtml: String { get }

UUID

  • 创建一个UUID字符串,示例:"D1178E50-2A4D-4F1F-9BD3-F6AAB00E06B1"。也可调用NSUUID.UUID.UUIDString

    Declaration

    Swift

    public static var uuidString: String { get }

Available where Base == String

  • 是否符合正则表达式 示例:用户名:^[a-zA-Z][a-zA-Z0-9_]{4,13}$ 密码:^[a-zA-Z0-9_]{6,20}$ 昵称:^[a-zA-Z0-9_\u4e00-\u9fa5]{4,14}$

    @param regex 正则表达式

    Declaration

    Swift

    public func isFormatRegex(_ regex: String) -> Bool
  • 是否是手机号

    Declaration

    Swift

    public func isFormatMobile() -> Bool
  • 是否是座机号

    Declaration

    Swift

    public func isFormatTelephone() -> Bool
  • 是否是整数

    Declaration

    Swift

    public func isFormatInteger() -> Bool
  • 是否是数字

    Declaration

    Swift

    public func isFormatNumber() -> Bool
  • 是否是合法金额,两位小数点

    Declaration

    Swift

    public func isFormatMoney() -> Bool
  • 是否是身份证号

    Declaration

    Swift

    public func isFormatIdcard() -> Bool
  • 是否是银行卡号

    Declaration

    Swift

    public func isFormatBankcard() -> Bool
  • 是否是车牌号

    Declaration

    Swift

    public func isFormatCarno() -> Bool
  • 是否是邮政编码

    Declaration

    Swift

    public func isFormatPostcode() -> Bool
  • 是否是工商税号

    Declaration

    Swift

    public func isFormatTaxno() -> Bool
  • 是否是邮箱

    Declaration

    Swift

    public func isFormatEmail() -> Bool
  • 是否是URL

    Declaration

    Swift

    public func isFormatUrl() -> Bool
  • 是否是HTML

    Declaration

    Swift

    public func isFormatHtml() -> Bool
  • 是否是IP

    Declaration

    Swift

    public func isFormatIp() -> Bool
  • 是否全是中文

    Declaration

    Swift

    public func isFormatChinese() -> Bool
  • 是否是合法时间,格式:yyyy-MM-dd HH:mm:ss

    Declaration

    Swift

    public func isFormatDatetime() -> Bool
  • 是否是合法时间戳,格式:1301234567

    Declaration

    Swift

    public func isFormatTimestamp() -> Bool
  • 是否是坐标点字符串,格式:latitude,longitude

    Declaration

    Swift

    public func isFormatCoordinate() -> Bool

Map

  • 生成苹果地图地址外部URL

    @param addr 显示地址,格式latitude,longitude或搜索地址 @param options 可选附加参数,如@{@“ll”: @“latitude,longitude”, @“z”: @“14”} @return NSURL

    Declaration

    Swift

    public static func appleMapsURL(withAddr addr: String?, options: [AnyHashable : Any]? = nil) -> URL?
  • 生成苹果地图导航外部URL

    @param saddr 导航起始点,格式latitude,longitude或搜索地址 @param daddr 导航结束点,格式latitude,longitude或搜索地址 @param options 可选附加参数,如@{@“ll”: @“latitude,longitude”, @“z”: @“14”} @return NSURL

    Declaration

    Swift

    public static func appleMapsURL(withSaddr saddr: String?, daddr: String?, options: [AnyHashable : Any]? = nil) -> URL?
  • 生成谷歌地图外部URL,URL SCHEME为:comgooglemaps

    @param addr 显示地址,格式latitude,longitude或搜索地址 @param options 可选附加参数,如@{@“center”: @“latitude,longitude”, @“zoom”: @“14”} @return NSURL

    Declaration

    Swift

    public static func googleMapsURL(withAddr addr: String?, options: [AnyHashable : Any]? = nil) -> URL?
  • 生成谷歌地图导航外部URL,URL SCHEME为:comgooglemaps

    @param saddr 导航起始点,格式latitude,longitude或搜索地址 @param daddr 导航结束点,格式latitude,longitude或搜索地址 @param mode 导航模式,支持driving|transit|bicycling|walking,默认driving @param options 可选附加参数,如@{@“center”: @“latitude,longitude”, @“zoom”: @“14”, @“dirflg”: @“t,h”} @return NSURL

    Declaration

    Swift

    public static func googleMapsURL(withSaddr saddr: String?, daddr: String?, mode: String?, options: [AnyHashable : Any]? = nil) -> URL?
  • 生成百度地图外部URL,URL SCHEME为:baidumap

    @param addr 显示地址,格式latitude,longitude或搜索地址 @param options 可选附加参数,如@{@“src”: @“app”, @“zoom”: @“14”, @“coord_type”: @“默认gcj02|wgs84|bd09ll”} @return NSURL

    Declaration

    Swift

    public static func baiduMapsURL(withAddr addr: String?, options: [AnyHashable : Any]? = nil) -> URL?
  • 生成百度地图导航外部URL,URL SCHEME为:baidumap

    @param saddr 导航起始点,格式latitude,longitude或搜索地址 @param daddr 导航结束点,格式latitude,longitude或搜索地址 @param mode 导航模式,支持driving|transit|navigation|riding|walking,默认driving @param options 可选附加参数,如@{@“src”: @“app”, @“zoom”: @“14”, @“coord_type”: @“默认gcj02|wgs84|bd09ll”} @return NSURL

    Declaration

    Swift

    public static func baiduMapsURL(withSaddr saddr: String?, daddr: String?, mode: String?, options: [AnyHashable : Any]? = nil) -> URL?

Available where Base == URLRequest

  • 生成对应curl命令,方便调试和测试

    Declaration

    Swift

    public func curlCommand() -> String

OcrObject

  • 识别图片文字,可设置语言(zh-CN,en-US)等,完成时主线程回调结果

    Declaration

    Swift

    @available(iOS 13.0, *)
    public static func recognizeText(in image: CGImage, configuration: ((VNRecognizeTextRequest) -> Void)?, completion: @escaping ([OcrObject]) -> Void)

App

  • 读取应用信息字典

    Declaration

    Swift

    public static func appInfo(_ key: String) -> Any?

Debug

  • 是否是盗版(不是从AppStore安装)

    Declaration

    Swift

    public static var isPirated: Bool { get }
  • 是否是Testflight版本

    Declaration

    Swift

    public static var isTestflight: Bool { get }

URL

  • 播放内置声音文件

    Declaration

    Swift

    @discardableResult
    public static func playAlert(_ file: String) -> SystemSoundID
  • 停止播放内置声音文件

    Declaration

    Swift

    public static func stopAlert(_ soundId: SystemSoundID)
  • 播放内置震动

    Declaration

    Swift

    public static func playVibrate()
  • 语音朗读文字,可指定语言(如zh-CN)

    Declaration

    Swift

    public static func readText(_ text: String, language: String?)

Available where Base: UIBezierPath

Bezier

  • Undocumented

    Declaration

    Swift

    public static func lines(points: [NSValue]) -> UIBezierPath
  • Undocumented

    Declaration

    Swift

    public static func quadCurvedPath(points: [NSValue]) -> UIBezierPath
  • Undocumented

    Declaration

    Swift

    public static func middlePoint(_ p1: CGPoint, with p2: CGPoint) -> CGPoint
  • Undocumented

    Declaration

    Swift

    public static func controlPoint(_ p1: CGPoint, with p2: CGPoint) -> CGPoint
  • Undocumented

    Declaration

    Swift

    public static func radian(degree: CGFloat) -> CGFloat
  • Undocumented

    Declaration

    Swift

    public static func degree(radian: CGFloat) -> CGFloat
  • Undocumented

    Declaration

    Swift

    public static func linePoints(rect: CGRect, direction: UISwipeGestureRecognizer.Direction) -> [NSValue]

Shape

  • Undocumented

    Declaration

    Swift

    public static func shapeCircle(_ frame: CGRect, percent: Float, degree: CGFloat) -> UIBezierPath
  • Undocumented

    Declaration

    Swift

    public static func shapeHeart(_ frame: CGRect) -> UIBezierPath
  • Undocumented

    Declaration

    Swift

    public static func shapeStar(_ frame: CGRect) -> UIBezierPath
  • Undocumented

    Declaration

    Swift

    public static func shapeStars(_ count: UInt, frame: CGRect, spacing: CGFloat) -> UIBezierPath
  • Undocumented

    Declaration

    Swift

    public static func shapePlus(_ frame: CGRect) -> UIBezierPath
  • Undocumented

    Declaration

    Swift

    public static func shapeMinus(_ frame: CGRect) -> UIBezierPath
  • Undocumented

    Declaration

    Swift

    public static func shapeCross(_ frame: CGRect) -> UIBezierPath
  • Undocumented

    Declaration

    Swift

    public static func shapeCheck(_ frame: CGRect) -> UIBezierPath
  • Undocumented

    Declaration

    Swift

    public static func shapeFold(_ frame: CGRect, direction: UISwipeGestureRecognizer.Direction) -> UIBezierPath
  • Undocumented

    Declaration

    Swift

    public static func shapeArrow(_ frame: CGRect, direction: UISwipeGestureRecognizer.Direction) -> UIBezierPath
  • Undocumented

    Declaration

    Swift

    public static func shapeTriangle(_ frame: CGRect, direction: UISwipeGestureRecognizer.Direction) -> UIBezierPath

Available where Base: UIControl

  • Undocumented

    Declaration

    Swift

    public var touchEventInterval: TimeInterval { get set }

Available where Base: UIButton

  • 设置按钮倒计时,从window移除时自动取消。等待时按钮disabled,非等待时enabled。时间支持格式化,示例:重新获取(%lds)

    Declaration

    Swift

    @discardableResult
    public func startCountDown(_ seconds: Int, title: String, waitTitle: String) -> DispatchSource

Available where Base: UISwitch

  • 切换开关状态

    Declaration

    Swift

    public func toggle(_ animated: Bool = true)

Available where Base: UICollectionView

Available where Base: UICollectionViewFlowLayout

  • 设置Header和Footer是否悬停,支持iOS9+

    Declaration

    Swift

    public func hover(header: Bool, footer: Bool)

Color

Image

  • Undocumented

    Declaration

    Swift

    public static func color(image: UIImage) -> UIColor
  • Undocumented

    Declaration

    Swift

    public static func color(image: UIImage, point: CGPoint) -> UIColor?

Gradient

  • 创建渐变颜色,支持四个方向,默认向下Down

    @param size 渐变尺寸,非渐变边可以设置为1。如CGSizeMake(1, 50) @param colors 渐变颜色,CGColor数组,如:@[(bridge id)[UIColor redColor].CGColor, (bridge id)[UIColor blueColor].CGColor] @param locations 渐变位置,传NULL时均分,如:CGFloat locations[] = {0.0, 1.0}; @param direction 渐变方向,自动计算startPoint和endPoint,支持四个方向,默认向下Down @return 渐变色

    Declaration

    Swift

    public static func gradientColor(size: CGSize, colors: [Any], locations: UnsafePointer<CGFloat>?, direction: UISwipeGestureRecognizer.Direction) -> UIColor
  • 创建渐变颜色

    @param size 渐变尺寸,非渐变边可以设置为1。如CGSizeMake(1, 50) @param colors 渐变颜色,CGColor数组,如:@[(bridge id)[UIColor redColor].CGColor, (bridge id)[UIColor blueColor].CGColor] @param locations 渐变位置,传NULL时均分,如:CGFloat locations[] = {0.0, 1.0}; @param startPoint 渐变开始点,需要根据rect计算 @param endPoint 渐变结束点,需要根据rect计算 @return 渐变色

    Declaration

    Swift

    public static func gradientColor(size: CGSize, colors: [Any], locations: UnsafePointer<CGFloat>?, startPoint: CGPoint, endPoint: CGPoint) -> UIColor

Jailbroken

  • Undocumented

    Declaration

    Swift

    public static var isJailbroken: Bool { get }

Network

  • Undocumented

    Declaration

    Swift

    public static var ipAddress: String? { get }
  • Undocumented

    Declaration

    Swift

    public static var hostName: String? { get }
  • Undocumented

    Declaration

    Swift

    public static var carrierName: String? { get }
  • Undocumented

    Declaration

    Swift

    public static var networkType: String? { get }

Font

  • 是否是粗体

    Declaration

    Swift

    public var isBold: Bool { get }
  • 是否是斜体

    Declaration

    Swift

    public var isItalic: Bool { get }
  • 当前字体的粗体字体

    Declaration

    Swift

    public var boldFont: UIFont { get }
  • 当前字体的非粗体字体

    Declaration

    Swift

    public var nonBoldFont: UIFont { get }
  • 当前字体的斜体字体

    Declaration

    Swift

    public var italicFont: UIFont { get }
  • 当前字体的非斜体字体

    Declaration

    Swift

    public var nonItalicFont: UIFont { get }

Height

  • Undocumented

    Declaration

    Swift

    public var spaceHeight: CGFloat { get }
  • Undocumented

    Declaration

    Swift

    public func lineSpacing(multiplier: CGFloat) -> CGFloat
  • Undocumented

    Declaration

    Swift

    public func lineHeight(multiplier: CGFloat) -> CGFloat
  • 计算当前字体与指定字体居中对齐的偏移值

    Declaration

    Swift

    public func baselineOffset(_ font: UIFont) -> CGFloat

Color

  • 获取灰度图

    Declaration

    Swift

    public var grayImage: UIImage? { get }
  • 取图片某一点的颜色

    Declaration

    Swift

    public func color(atPoint point: CGPoint) -> UIColor?
  • 取图片某一像素的颜色

    Declaration

    Swift

    public func color(atPixel pixel: CGPoint) -> UIColor?
  • 获取图片的平均颜色

    Declaration

    Swift

    public var averageColor: UIColor { get }

Effect

  • 倒影图片

    Declaration

    Swift

    public func image(reflectScale: CGFloat) -> UIImage?
  • 倒影图片

    Declaration

    Swift

    public func image(reflectScale: CGFloat, gap: CGFloat, alpha: CGFloat) -> UIImage?
  • 阴影图片

    Declaration

    Swift

    public func image(shadowColor: UIColor, offset: CGSize, blur: CGFloat) -> UIImage?
  • 获取装饰图片

    Declaration

    Swift

    public var maskImage: UIImage { get }
  • 高斯模糊图片,默认模糊半径为10,饱和度为1

    Declaration

    Swift

    public func image(blurRadius: CGFloat, saturationDelta: CGFloat, tintColor: UIColor?, maskImage: UIImage?) -> UIImage?

Alpha

  • 如果没有透明通道,增加透明通道

    Declaration

    Swift

    public var alphaImage: UIImage { get }

View

  • 截取View所有视图,包括旋转缩放效果

    Declaration

    Swift

    public static func image(view: UIView, limitWidth: CGFloat) -> UIImage?

Icon

  • 获取AppIcon图片

    Declaration

    Swift

    public static func appIconImage() -> UIImage?
  • 获取AppIcon指定尺寸图片,名称格式:AppIcon60x60

    Declaration

    Swift

    public static func appIconImage(size: CGSize) -> UIImage?

Pdf

  • 从Pdf数据或者路径创建指定大小UIImage

    Declaration

    Swift

    public static func image(pdf path: Any, size: CGSize = .zero) -> UIImage?

Emoji

  • 从Emoji字符串创建指定大小UIImage

    Declaration

    Swift

    public static func image(emoji: String, size: CGFloat) -> UIImage?

Gradient

  • 创建渐变颜色UIImage,支持四个方向,默认向下Down

    @param size 图片大小 @param colors 渐变颜色,CGColor数组,如:@[(bridge id)[UIColor redColor].CGColor, (bridge id)[UIColor blueColor].CGColor] @param locations 渐变位置,传NULL时均分,如:CGFloat locations[] = {0.0, 1.0}; @param direction 渐变方向,自动计算startPoint和endPoint,支持四个方向,默认向下Down @return 渐变颜色UIImage

    Declaration

    Swift

    public static func gradientImage(size: CGSize, colors: [Any], locations: UnsafePointer<CGFloat>?, direction: UISwipeGestureRecognizer.Direction) -> UIImage?
  • 创建渐变颜色UIImage

    @param size 图片大小 @param colors 渐变颜色,CGColor数组,如:@[(bridge id)[UIColor redColor].CGColor, (bridge id)[UIColor blueColor].CGColor] @param locations 渐变位置,传NULL时均分,如:CGFloat locations[] = {0.0, 1.0}; @param startPoint 渐变开始点,需要根据rect计算 @param endPoint 渐变结束点,需要根据rect计算 @return 渐变颜色UIImage

    Declaration

    Swift

    public static func gradientImage(size: CGSize, colors: [Any], locations: UnsafePointer<CGFloat>?, startPoint: CGPoint, endPoint: CGPoint) -> UIImage?

Mode

  • 设置图片模式为ScaleAspectFill,自动拉伸不变形,超过区域隐藏。可通过appearance统一设置

    Declaration

    Swift

    public func setContentModeAspectFill()
  • 设置指定图片模式,超过区域隐藏。可通过appearance统一设置

    Declaration

    Swift

    public func setContentMode(_ contentMode: UIView.ContentMode)

Face

Reflect

  • 倒影效果

    Declaration

    Swift

    public func reflect()

Watermark

  • 图片水印

    Declaration

    Swift

    public func setImage(_ image: UIImage, watermarkImage: UIImage, in rect: CGRect)
  • 文字水印,指定区域

    Declaration

    Swift

    public func setImage(_ image: UIImage, watermarkString: NSAttributedString, in rect: CGRect)
  • 文字水印,指定坐标

    Declaration

    Swift

    public func setImage(_ image: UIImage, watermarkString: NSAttributedString, at point: CGPoint)

Size

  • Undocumented

    Declaration

    Swift

    public var textSize: CGSize { get }
  • Undocumented

    Declaration

    Swift

    public var attributedTextSize: CGSize { get }

Available where Base: UILabel

  • 调试功能,打开后会在 label 第一行文字里把 descender、xHeight、capHeight、lineHeight 所在的位置以线条的形式标记出来。 对这些属性的解释可以看这篇文章 https://www.rightpoint.com/rplabs/ios-tracking-typography

    Declaration

    Swift

    public var showPrincipalLines: Bool { get set }
  • 当打开 showPrincipalLines 时,通过这个属性控制线条的颜色,默认为 半透明红色

    Declaration

    Swift

    public var principalLineColor: UIColor { get set }

Available where Base: UNUserNotificationCenter

  • 创建本地通知,badge为0时不显示(nil时不修改),soundName为default时为默认声音

    Declaration

    Swift

    public static func localNotification(title: String?, subtitle: String?, body: String?, userInfo: [AnyHashable : Any]?, category: String?, badge: NSNumber?, soundName: String?, block: ((UNMutableNotificationContent) -> Void)? = nil) -> UNMutableNotificationContent
  • 注册本地通知,trigger为nil时立即触发,iOS10+

    Declaration

    Swift

    public static func registerLocalNotification(_ identifier: String, content: UNNotificationContent, trigger: UNNotificationTrigger?)
  • 删除未发出的本地通知,iOS10+

    Declaration

    Swift

    public static func removePendingNotification(_ identifiers: [String])
  • 删除所有未发出的本地通知,iOS10+

    Declaration

    Swift

    public static func removeAllPendingNotifications()
  • 删除已发出的本地通知,iOS10+

    Declaration

    Swift

    public static func removeDeliveredNotification(_ identifiers: [String])
  • 删除所有已发出的本地通知,iOS10+

    Declaration

    Swift

    public static func removeAllDeliveredNotifications()

Available where Base: UINavigationBar

  • 导航栏内容视图,iOS11+才存在,显示item和titleView等

    Declaration

    Swift

    public var contentView: UIView? { get }
  • 导航栏大标题视图,显示时才有值。如果要设置背景色,可使用fwBackgroundView.backgroundColor

    Declaration

    Swift

    public var largeTitleView: UIView? { get }
  • 导航栏大标题高度,与是否隐藏无关

    Declaration

    Swift

    public static var largeTitleHeight: CGFloat { get }

Available where Base: UIToolbar

  • 工具栏内容视图,iOS11+才存在,显示item等

    Declaration

    Swift

    public var contentView: UIView? { get }
  • 工具栏背景视图,显示背景色和背景图片等。如果标签栏同时显示,背景视图高度也会包含标签栏高度

    Declaration

    Swift

    public var backgroundView: UIView? { get }

Content

  • 内容视图,子视图需添加到本视图,布局约束完整时可自动滚动

    Declaration

    Swift

    public var contentView: UIView { get }

Frame

  • contentSize.width

    Declaration

    Swift

    public var contentWidth: CGFloat { get set }
  • contentSize.height

    Declaration

    Swift

    public var contentHeight: CGFloat { get set }
  • contentOffset.x

    Declaration

    Swift

    public var contentOffsetX: CGFloat { get set }
  • contentOffset.y

    Declaration

    Swift

    public var contentOffsetY: CGFloat { get set }

Scroll

  • UIScrollView真正的inset,iOS11+使用adjustedContentInset,iOS11以下使用contentInset

    Declaration

    Swift

    public var contentInset: UIEdgeInsets { get }
  • 当前滚动方向,如果多个方向滚动,取绝对值较大的一方,失败返回0

    Declaration

    Swift

    public var scrollDirection: UISwipeGestureRecognizer.Direction { get }
  • 当前滚动进度,滚动绝对值相对于当前视图的宽或高

    Declaration

    Swift

    public var scrollPercent: CGFloat { get }
  • 计算指定方向的滚动进度

    Declaration

    Swift

    public func scrollPercent(of direction: UISwipeGestureRecognizer.Direction) -> CGFloat

Content

  • 单独禁用内边距适应,同上。注意appearance设置时会影响到系统控制器如UIImagePickerController等

    Declaration

    Swift

    public func contentInsetAdjustmentNever()

Keyboard

  • 是否滚动时收起键盘,默认NO

    Declaration

    Swift

    public var keyboardDismissOnDrag: Bool { get set }

Gesture

  • 是否开始识别pan手势

    Declaration

    Swift

    public var shouldBegin: ((UIGestureRecognizer) -> Bool)? { get set }
  • 是否允许同时识别多个手势

    Declaration

    Swift

    public var shouldRecognizeSimultaneously: ((UIGestureRecognizer, UIGestureRecognizer) -> Bool)? { get set }
  • 是否另一个手势识别失败后,才能识别pan手势

    Declaration

    Swift

    public var shouldRequireFailure: ((UIGestureRecognizer, UIGestureRecognizer) -> Bool)? { get set }
  • 是否pan手势识别失败后,才能识别另一个手势

    Declaration

    Swift

    public var shouldBeRequiredToFail: ((UIGestureRecognizer, UIGestureRecognizer) -> Bool)? { get set }

Hover

  • 设置自动布局视图悬停到指定父视图固定位置,在scrollViewDidScroll:中调用即可

    @param view 需要悬停的视图,须占满fromSuperview @param fromSuperview 起始的父视图,须是scrollView的子视图 @param toSuperview 悬停的目标视图,须是scrollView的父级视图,一般控制器self.view @param toPosition 需要悬停的目标位置,相对于toSuperview的originY位置 @return 相对于悬浮位置的距离,可用来设置导航栏透明度等

    Declaration

    Swift

    @discardableResult
    public func hoverView(_ view: UIView, fromSuperview: UIView, toSuperview: UIView, toPosition: CGFloat) -> CGFloat

Factory

  • 快速创建通用配置滚动视图

    Declaration

    Swift

    public static func scrollView() -> Base

Available where Base: UIGestureRecognizer

  • 获取手势直接作用的view,不同于view,此处是view的subview

    Declaration

    Swift

    public weak var targetView: UIView? { get }
  • 是否正在拖动中:Began || Changed

    Declaration

    Swift

    public var isTracking: Bool { get }
  • 是否是激活状态: isEnabled && (Began || Changed)

    Declaration

    Swift

    public var isActive: Bool { get }

Available where Base: UIPanGestureRecognizer

  • 当前滑动方向,如果多个方向滑动,取绝对值较大的一方,失败返回0

    Declaration

    Swift

    public var swipeDirection: UISwipeGestureRecognizer.Direction { get }
  • 当前滑动进度,滑动绝对值相对于手势视图的宽或高

    Declaration

    Swift

    public var swipePercent: CGFloat { get }
  • 计算指定方向的滑动进度

    Declaration

    Swift

    public func swipePercent(of direction: UISwipeGestureRecognizer.Direction) -> CGFloat

Available where Base: UISearchBar

  • Undocumented

    Declaration

    Swift

    public var contentInset: UIEdgeInsets { get set }
  • Undocumented

    Declaration

    Swift

    public var cancelButtonInset: UIEdgeInsets { get set }
  • Undocumented

    Declaration

    Swift

    public weak var textField: UITextField? { get }
  • Undocumented

    Declaration

    Swift

    public weak var cancelButton: UIButton? { get }
  • Undocumented

    Declaration

    Swift

    public var backgroundColor: UIColor? { get set }
  • Undocumented

    Declaration

    Swift

    public var textFieldBackgroundColor: UIColor? { get set }
  • Undocumented

    Declaration

    Swift

    public var searchIconOffset: CGFloat { get set }
  • Undocumented

    Declaration

    Swift

    public var searchTextOffset: CGFloat { get set }
  • Undocumented

    Declaration

    Swift

    public var searchIconCenter: Bool { get set }
  • Undocumented

    Declaration

    Swift

    public var forceCancelButtonEnabled: Bool { get set }

Available where Base: UITableView

  • Undocumented

    Declaration

    Swift

    public var delegate: TableViewDelegate { get }
  • Undocumented

    Declaration

    Swift

    public static func tableView() -> Base
  • Undocumented

    Declaration

    Swift

    public static func tableView(_ style: UITableView.Style) -> Base
  • 是否启动高度估算布局,启用后需要子视图布局完整,无需实现heightForRow方法(iOS11默认启用,会先cellForRow再heightForRow)

    Declaration

    Swift

    public var estimatedLayout: Bool { get set }
  • 清空Grouped样式默认多余边距,注意CGFLOAT_MIN才会生效,0不会生效

    Declaration

    Swift

    public func resetGroupedStyle()
  • 设置Plain样式sectionHeader和Footer跟随滚动(不悬停),在scrollViewDidScroll:中调用即可(需先禁用内边距适应)

    Declaration

    Swift

    public func follow(header: CGFloat, footer: CGFloat)
  • reloadData完成回调

    Declaration

    Swift

    public func reloadData(completion: (() -> Void)?)
  • reloadData清空尺寸缓存

    Declaration

    Swift

    public func reloadDataWithoutCache()
  • reloadData禁用动画

    Declaration

    Swift

    public func reloadDataWithoutAnimation()
  • reloadSections禁用动画

    Declaration

    Swift

    public func reloadSectionsWithoutAnimation(_ sections: IndexSet)
  • reloadRows禁用动画

    Declaration

    Swift

    public func reloadRowsWithoutAnimation(_ indexPaths: [IndexPath])
  • 刷新高度等,不触发reload方式

    Declaration

    Swift

    public func performUpdates(_ updates: (() -> Void)?)
  • 全局清空TableView默认多余边距

    Declaration

    Swift

    public static func resetTableStyle()

Available where Base: UITableViewCell

  • 延迟加载背景视图,处理section圆角、阴影等。会自动设置backgroundView

    Declaration

    Swift

    public var backgroundView: TableViewCellBackgroundView { get }

Menu

  • 是否禁用长按菜单(拷贝、选择、粘贴等),默认NO

    Declaration

    Swift

    public var menuDisabled: Bool { get set }

Select

  • 自定义光标颜色

    Declaration

    Swift

    public var cursorColor: UIColor { get set }
  • 自定义光标大小,不为0才会生效,默认zero不生效

    Declaration

    Swift

    public var cursorRect: CGRect { get set }
  • 获取及设置当前选中文字范围

    Declaration

    Swift

    public var selectedRange: NSRange { get set }
  • 移动光标到最后

    Declaration

    Swift

    public func selectAllRange()
  • 移动光标到指定位置,兼容动态text赋值

    Declaration

    Swift

    public func moveCursor(_ offset: Int)

Menu

  • 是否禁用长按菜单(拷贝、选择、粘贴等),默认NO

    Declaration

    Swift

    public var menuDisabled: Bool { get set }

Select

  • 自定义光标颜色

    Declaration

    Swift

    public var cursorColor: UIColor { get set }
  • 自定义光标大小,不为0才会生效,默认zero不生效

    Declaration

    Swift

    public var cursorRect: CGRect { get set }
  • 获取及设置当前选中文字范围

    Declaration

    Swift

    public var selectedRange: NSRange { get set }
  • 移动光标到最后

    Declaration

    Swift

    public func selectAllRange()
  • 移动光标到指定位置,兼容动态text赋值

    Declaration

    Swift

    public func moveCursor(_ offset: Int)

Size

  • 计算当前文本所占尺寸,包含textContainerInset,需frame或者宽度布局完整

    Declaration

    Swift

    public var textSize: CGSize { get }
  • 计算当前属性文本所占尺寸,包含textContainerInset,需frame或者宽度布局完整,attributedText需指定字体

    Declaration

    Swift

    public var attributedTextSize: CGSize { get }

Transform

  • 获取当前view的transform scale x

    Declaration

    Swift

    public var scaleX: CGFloat { get }
  • 获取当前view的transform scale y

    Declaration

    Swift

    public var scaleY: CGFloat { get }
  • 获取当前view的transform translation x

    Declaration

    Swift

    public var translationX: CGFloat { get }
  • 获取当前view的transform translation y

    Declaration

    Swift

    public var translationY: CGFloat { get }

Subview

  • 移除所有子视图

    Declaration

    Swift

    public func removeAllSubviews()
  • 递归查找指定子类的第一个视图

    Declaration

    Swift

    public func subview(of clazz: AnyClass) -> UIView?
  • 递归查找指定条件的第一个视图

    Declaration

    Swift

    public func subview(of block: @escaping (UIView) -> Bool) -> UIView?
  • 添加到父视图,nil时为从父视图移除

    Declaration

    Swift

    public func move(toSuperview view: UIView?)

Snapshot

  • 图片截图

    Declaration

    Swift

    public var snapshotImage: UIImage? { get }
  • Pdf截图

    Declaration

    Swift

    public var snapshotPdf: Data? { get }

Drag

  • 是否启用拖动,默认NO

    Declaration

    Swift

    public var dragEnabled: Bool { get set }
  • 拖动手势,延迟加载

    Declaration

    Swift

    public var dragGesture: UIPanGestureRecognizer { get }
  • 设置拖动限制区域,默认CGRectZero,无限制

    Declaration

    Swift

    public var dragLimit: CGRect { get set }
  • 设置拖动动作有效区域,默认self.frame

    Declaration

    Swift

    public var dragArea: CGRect { get set }
  • 是否允许横向拖动(X),默认YES

    Declaration

    Swift

    public var dragHorizontal: Bool { get set }
  • 是否允许纵向拖动(Y),默认YES

    Declaration

    Swift

    public var dragVertical: Bool { get set }
  • 开始拖动回调

    Declaration

    Swift

    public var dragStartedBlock: ((UIView) -> Void)? { get set }
  • 拖动移动回调

    Declaration

    Swift

    public var dragMovedBlock: ((UIView) -> Void)? { get set }
  • 结束拖动回调

    Declaration

    Swift

    public var dragEndedBlock: ((UIView) -> Void)? { get set }

Animation

  • 添加UIView动画,使用默认动画参数 @note 如果动画过程中需要获取进度,可通过添加CADisplayLink访问self.layer.presentationLayer获取,下同

    @param block 动画代码块 @param completion 完成事件

    Declaration

    Swift

    public func addAnimation(block: @escaping () -> Void, completion: ((Bool) -> Void)? = nil)
  • 添加UIView动画

    @param block 动画代码块 @param duration 持续时间 @param completion 完成事件

    Declaration

    Swift

    public func addAnimation(block: @escaping () -> Void, duration: TimeInterval, completion: ((Bool) -> Void)? = nil)
  • 添加UIView动画

    @param curve 动画速度 @param transition 动画类型 @param duration 持续时间,默认0.2 @param completion 完成事件

    Declaration

    Swift

    public func addAnimation(curve: UIView.AnimationCurve, transition: UIView.AnimationTransition, duration: TimeInterval, completion: ((Bool) -> Void)? = nil)
  • 添加CABasicAnimation动画

    @param keyPath 动画路径 @param fromValue 开始值 @param toValue 结束值 @param duration 持续时间,0为默认(0.25秒) @param completion 完成事件 @return CABasicAnimation

    Declaration

    Swift

    @discardableResult
    public func addAnimation(keyPath: String, fromValue: Any, toValue: Any, duration: CFTimeInterval, completion: ((Bool) -> Void)? = nil) -> CABasicAnimation
  • 添加转场动画

    @param option 动画选项 @param block 动画代码块 @param duration 持续时间 @param completion 完成事件

    Declaration

    Swift

    public func addTransition(option: UIView.AnimationOptions = [], block: @escaping () -> Void, duration: TimeInterval, completion: ((Bool) -> Void)? = nil)
  • 添加转场动画,可指定animationsEnabled,一般用于window切换rootViewController

    @param option 动画选项 @param block 动画代码块 @param duration 持续时间 @param animationsEnabled 是否启用动画 @param completion 完成事件

    Declaration

    Swift

    public func addTransition(option: UIView.AnimationOptions = [], block: @escaping () -> Void, duration: TimeInterval, animationsEnabled: Bool, completion: ((Bool) -> Void)? = nil)
  • 添加转场动画

    @param toView 目标视图 @param option 动画选项 @param duration 持续时间 @param completion 完成事件

    Declaration

    Swift

    public func addTransition(toView: UIView, option: UIView.AnimationOptions = [], duration: TimeInterval, completion: ((Bool) -> Void)? = nil)
  • 添加CATransition转场动画 备注:移除动画可调用[self fwRemoveAnimation]

    @param type 动画类型 @param subtype 子类型 @param timingFunction 动画速度 @param duration 持续时间,0为默认(0.25秒) @param completion 完成事件 @return CATransition

    Declaration

    Swift

    @discardableResult
    public func addTransition(type: String, subtype: String?, timingFunction: String?, duration: CFTimeInterval, completion: ((Bool) -> Void)? = nil) -> CATransition
  • 移除单个框架视图动画

    Declaration

    Swift

    public func removeAnimation()
  • 移除所有视图动画

    Declaration

    Swift

    public func removeAllAnimations()

Custom

  • 绘制动画

    @param layer CAShapeLayer层 @param duration 持续时间 @param completion 完成回调 @return CABasicAnimation

    Declaration

    Swift

    @discardableResult
    public func stroke(layer: CAShapeLayer, duration: TimeInterval, completion: ((Bool) -> Void)? = nil) -> CABasicAnimation
  • 水平摇摆动画

    @param times 摇摆次数,默认10 @param delta 摇摆宽度,默认5 @param duration 单次时间,默认0.03 @param completion 完成回调

    Declaration

    Swift

    public func shake(times: Int, delta: CGFloat, duration: TimeInterval, completion: ((Bool) -> Void)? = nil)
  • 渐显隐动画

    @param alpha 透明度 @param duration 持续时长 @param completion 完成回调

    Declaration

    Swift

    public func fade(alpha: Float, duration: TimeInterval, completion: ((Bool) -> Void)? = nil)
  • 渐变代码块动画

    @param block 动画代码块,比如调用imageView.setImage:方法 @param duration 持续时长,建议0.5 @param completion 完成回调

    Declaration

    Swift

    public func fade(block: @escaping () -> Void, duration: TimeInterval, completion: ((Bool) -> Void)? = nil)
  • 旋转动画

    @param degree 旋转度数,备注:逆时针需设置-179.99。使用CAAnimation无此问题 @param duration 持续时长 @param completion 完成回调

    Declaration

    Swift

    public func rotate(degree: CGFloat, duration: TimeInterval, completion: ((Bool) -> Void)? = nil)
  • 缩放动画

    @param scaleX X轴缩放率 @param scaleY Y轴缩放率 @param duration 持续时长 @param completion 完成回调

    Declaration

    Swift

    public func scale(scaleX: Float, scaleY: Float, duration: TimeInterval, completion: ((Bool) -> Void)? = nil)
  • 移动动画

    @param point 目标点 @param duration 持续时长 @param completion 完成回调

    Declaration

    Swift

    public func move(point: CGPoint, duration: TimeInterval, completion: ((Bool) -> Void)? = nil)
  • 移动变化动画

    @param frame 目标区域 @param duration 持续时长 @param completion 完成回调

    Declaration

    Swift

    public func move(frame: CGRect, duration: TimeInterval, completion: ((Bool) -> Void)? = nil)

Block

  • 取消动画效果执行block

    @param block 动画代码块 @param completion 完成事件

    Declaration

    Swift

    public static func animateNone(block: () -> Void, completion: (() -> Void)? = nil)
  • 执行block动画完成后执行指定回调

    @param block 动画代码块 @param completion 完成事件

    Declaration

    Swift

    public static func animate(block: () -> Void, completion: (() -> Void)? = nil)

Available where Base: CALayer

Available where Base: CAGradientLayer

  • 创建渐变层,需手工addLayer

    @param frame 渐变区域 @param colors 渐变颜色,CGColor数组,如[黑,白,黑] @param locations 渐变位置,0~1,如[0.25, 0.5, 0.75]对应颜色为[0-0.25黑,0.25-0.5黑渐变白,0.5-0.75白渐变黑,0.75-1黑] @param startPoint 渐变开始点,设置渐变方向,左上点为(0,0),右下点为(1,1) @param endPoint 渐变结束点 @return 渐变Layer

    Declaration

    Swift

    public static func gradientLayer(
        _ frame: CGRect,
        colors: [Any],
        locations: [NSNumber]?,
        startPoint: CGPoint,
        endPoint: CGPoint
    ) -> CAGradientLayer

Effect

  • 设置毛玻璃效果,使用UIVisualEffectView。内容需要添加到UIVisualEffectView.contentView

    @param style 毛玻璃效果样式

    Declaration

    Swift

    @discardableResult
    public func setBlurEffect(_ style: UIBlurEffect.Style) -> UIVisualEffectView?

Bezier

  • 绘制形状路径,需要在drawRect中调用

    @param bezierPath 绘制路径 @param strokeWidth 绘制宽度 @param strokeColor 绘制颜色 @param fillColor 填充颜色

    Declaration

    Swift

    public func drawBezierPath(_ bezierPath: UIBezierPath, strokeWidth: CGFloat, strokeColor: UIColor, fillColor: UIColor?)

Gradient

  • 绘制渐变颜色,需要在drawRect中调用,支持四个方向,默认向下Down

    @param rect 绘制区域 @param colors 渐变颜色,CGColor数组,如:@[(bridge id)[UIColor redColor].CGColor, (bridge id)[UIColor blueColor].CGColor] @param locations 渐变位置,传NULL时均分,如:CGFloat locations[] = {0.0, 1.0}; @param direction 渐变方向,自动计算startPoint和endPoint,支持四个方向,默认向下Down

    Declaration

    Swift

    public func drawLinearGradient(_ rect: CGRect, colors: [Any], locations: UnsafePointer<CGFloat>?, direction: UISwipeGestureRecognizer.Direction)
  • 绘制渐变颜色,需要在drawRect中调用

    @param rect 绘制区域 @param colors 渐变颜色,CGColor数组,如:@[(bridge id)[UIColor redColor].CGColor, (bridge id)[UIColor blueColor].CGColor] @param locations 渐变位置,传NULL时均分,如:CGFloat locations[] = {0.0, 1.0}; @param startPoint 渐变开始点,需要根据rect计算 @param endPoint 渐变结束点,需要根据rect计算

    Declaration

    Swift

    public func drawLinearGradient(_ rect: CGRect, colors: [Any], locations: UnsafePointer<CGFloat>?, startPoint: CGPoint, endPoint: CGPoint)
  • 添加渐变Layer

    @param frame 渐变区域 @param colors 渐变颜色,CGColor数组,如[黑,白,黑] @param locations 渐变位置,0~1,如[0.25, 0.5, 0.75]对应颜色为[0-0.25黑,0.25-0.5黑渐变白,0.5-0.75白渐变黑,0.75-1黑] @param startPoint 渐变开始点,设置渐变方向,左上点为(0,0),右下点为(1,1) @param endPoint 渐变结束点 @return 渐变Layer

    Declaration

    Swift

    @discardableResult
    public func addGradientLayer(_ frame: CGRect, colors: [Any], locations: [NSNumber]?, startPoint: CGPoint, endPoint: CGPoint) -> CAGradientLayer

Circle

  • 添加进度圆形Layer,可设置绘制颜色和宽度,返回进度CAShapeLayer用于动画,degree为起始角度,如-90

    Declaration

    Swift

    @discardableResult
    public func addCircleLayer(_ rect: CGRect, degree: CGFloat, progress: CGFloat, strokeColor: UIColor, strokeWidth: CGFloat) -> CAShapeLayer
  • 添加进度圆形Layer,可设置绘制底色和进度颜色,返回进度CAShapeLayer用于动画,degree为起始角度,如-90

    Declaration

    Swift

    @discardableResult
    public func addCircleLayer(_ rect: CGRect, degree: CGFloat, progress: CGFloat, progressColor: UIColor, strokeColor: UIColor, strokeWidth: CGFloat) -> CAShapeLayer
  • 添加渐变进度圆形Layer,返回渐变Layer容器,添加strokeEnd动画请使用layer.mask即可

    Declaration

    Swift

    @discardableResult
    public func addCircleLayer(_ rect: CGRect, degree: CGFloat, progress: CGFloat, gradientBlock: ((CALayer) -> Void)?, strokeColor: UIColor, strokeWidth: CGFloat) -> CALayer

Dash

  • 添加虚线Layer

    @param rect 虚线区域,从中心绘制 @param lineLength 虚线的宽度 @param lineSpacing 虚线的间距 @param lineColor 虚线的颜色 @return 虚线Layer

    Declaration

    Swift

    @discardableResult
    public func addDashLayer(_ rect: CGRect, lineLength: CGFloat, lineSpacing: CGFloat, lineColor: UIColor) -> CALayer

Available where Base: UIView

  • 获取当前 UIView 层级树信息

    Declaration

    Swift

    public var viewInfo: String { get }
  • 是否需要添加debug背景色,默认NO

    Declaration

    Swift

    public var showDebugColor: Bool { get set }
  • 是否每个view的背景色随机,如果不随机则统一使用半透明红色,默认NO

    Declaration

    Swift

    public var randomDebugColor: Bool { get set }
  • 是否需要添加debug边框,默认NO

    Declaration

    Swift

    public var showDebugBorder: Bool { get set }
  • 指定debug边框的颜色,默认半透明红色

    Declaration

    Swift

    public var debugBorderColor: UIColor { get set }

Child

  • 获取当前显示的子控制器,解决不能触发viewWillAppear等的bug

    Declaration

    Swift

    public func childViewController() -> UIViewController?
  • 设置当前显示的子控制器,解决不能触发viewWillAppear等的bug

    Declaration

    Swift

    public func setChildViewController(_ viewController: UIViewController)
  • 移除子控制器,解决不能触发viewWillAppear等的bug

    Declaration

    Swift

    public func removeChildViewController(_ viewController: UIViewController)
  • 添加子控制器到当前视图,解决不能触发viewWillAppear等的bug

    Declaration

    Swift

    public func addChildViewController(_ viewController: UIViewController, layout: ((UIView) -> Void)? = nil)
  • 添加子控制器到指定视图,解决不能触发viewWillAppear等的bug

    Declaration

    Swift

    public func addChildViewController(_ viewController: UIViewController, in view: UIView?, layout: ((UIView) -> Void)? = nil)

Previous

  • 获取和自身处于同一个UINavigationController里的上一个UIViewController

    Declaration

    Swift

    public weak var previousViewController: UIViewController? { get }

Style

  • 全局适配iOS13默认present样式(系统Automatic),仅当未自定义modalPresentationStyle时生效

    Declaration

    Swift

    public static var defaultModalPresentationStyle: UIModalPresentationStyle { get set }

Available where Base: UIWindow

  • 关闭所有弹出控制器,完成时回调。如果没有present控制器,直接回调

    Declaration

    Swift

    public func dismissViewControllers(_ completion: (() -> Void)? = nil)
  • 选中并获取指定索引TabBar根视图控制器,适用于Tabbar包含多个Navigation结构,找不到返回nil

    Declaration

    Swift

    @discardableResult
    public func selectTabBarIndex(_ index: UInt) -> UIViewController?
  • 选中并获取指定类TabBar根视图控制器,适用于Tabbar包含多个Navigation结构,找不到返回nil

    Declaration

    Swift

    @discardableResult
    public func selectTabBarController(_ viewController: AnyClass) -> UIViewController?
  • 选中并获取指定条件TabBar根视图控制器,适用于Tabbar包含多个Navigation结构,找不到返回nil

    Declaration

    Swift

    @discardableResult
    public func selectTabBarBlock(_ block: (UIViewController) -> Bool) -> UIViewController?