Wrapper
public class Wrapper<Base>
属性包装器
-
原始对象
Declaration
Swift
public let base: Base
-
初始化方法
Declaration
Swift
public init(_ base: Base)
-
Undocumented
Declaration
Swift
public var safeInt: Int { get }
-
Undocumented
Declaration
Swift
public var safeBool: Bool { get }
-
Undocumented
Declaration
Swift
public var safeFloat: Float { get }
-
Undocumented
Declaration
Swift
public var safeDouble: Double { get }
-
Undocumented
Declaration
Swift
public var safeString: String { get }
-
Undocumented
Declaration
Swift
public var safeNumber: NSNumber { get }
-
Undocumented
Declaration
Swift
public var safeArray: [Any] { get }
-
Undocumented
Declaration
Swift
public var safeDictionary: [AnyHashable : Any] { get }
-
Undocumented
Declaration
Swift
public var safeJSON: JSON { get }
-
监听某个点对点消息,可指定对象,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func observeMessage(_ name: Notification.Name, object: AnyObject? = nil, block: @escaping @Sendable (Notification) -> Void) -> NSObjectProtocol
Parameters
name
消息名称
object
消息对象,值为nil时表示所有
block
消息句柄
Return Value
监听者
-
主线程安全监听某个点对点消息,可指定对象,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func safeObserveMessage(_ name: Notification.Name, object: AnyObject? = nil, block: @escaping @MainActor @Sendable (Notification) -> Void) -> NSObjectProtocol
Parameters
name
消息名称
object
消息对象,值为nil时表示所有
block
消息句柄
Return Value
监听者
-
监听某个指定对象点对点消息,可指定对象,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func observeMessage(_ name: Notification.Name, object: AnyObject? = nil, target: AnyObject?, action: Selector) -> NSObjectProtocol
Parameters
name
消息名称
object
消息对象,值为nil时表示所有
target
消息目标
action
目标动作,参数为通知对象
Return Value
监听者
-
主线程安全监听某个指定对象点对点消息,可指定对象,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func safeObserveMessage(_ name: Notification.Name, object: AnyObject? = nil, target: AnyObject?, action: Selector) -> NSObjectProtocol
Parameters
name
消息名称
object
消息对象,值为nil时表示所有
target
消息目标
action
目标动作,参数为通知对象
Return Value
监听者
-
手工移除某个点对点消息指定监听,可指定对象
Declaration
Swift
public func unobserveMessage(_ name: Notification.Name, object: AnyObject? = nil, target: AnyObject? = nil, action: Selector? = nil)
Parameters
name
消息名称
object
消息对象,值为nil时表示所有
target
消息目标
action
目标动作
-
手工移除某个指定对象点对点消息指定监听
Declaration
Swift
@discardableResult public func unobserveMessage(observer: Any) -> Bool
Parameters
observer
监听者
-
手工移除所有点对点消息监听
Declaration
Swift
public func unobserveAllMessages()
-
发送点对点消息,附带对象和用户信息
Declaration
Swift
public func sendMessage(_ name: Notification.Name, object: AnyObject? = nil, userInfo: [AnyHashable : Any]? = nil, to receiver: some WrapperObject)
Parameters
name
消息名称
object
消息对象,默认nil
userInfo
用户信息,默认nil
receiver
消息接收者
-
发送点对点消息,附带对象和用户信息
Declaration
Swift
public static func sendMessage(_ name: Notification.Name, object: AnyObject? = nil, userInfo: [AnyHashable : Any]? = nil, to receiver: some WrapperObject)
Parameters
name
消息名称
object
消息对象,默认nil
userInfo
用户信息,默认nil
receiver
消息接收者
-
监听某个广播通知,可指定对象,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func observeNotification(_ name: Notification.Name, object: AnyObject? = nil, block: @escaping @Sendable (Notification) -> Void) -> NSObjectProtocol
Parameters
name
通知名称
object
通知对象,值为nil时表示所有
block
通知句柄
Return Value
监听者
-
主线程安全监听某个广播通知,可指定对象,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func safeObserveNotification(_ name: Notification.Name, object: AnyObject? = nil, block: @escaping @MainActor @Sendable (Notification) -> Void) -> NSObjectProtocol
Parameters
name
通知名称
object
通知对象,值为nil时表示所有
block
通知句柄
Return Value
监听者
-
监听某个广播通知,可指定对象,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func observeNotification(_ name: Notification.Name, object: AnyObject? = nil, target: AnyObject?, action: Selector) -> NSObjectProtocol
Parameters
name
通知名称
object
通知对象,值为nil时表示所有
target
通知目标
action
目标动作,参数为通知对象
Return Value
监听者
-
主线程安全监听某个广播通知,可指定对象,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func safeObserveNotification(_ name: Notification.Name, object: AnyObject? = nil, target: AnyObject?, action: Selector) -> NSObjectProtocol
Parameters
name
通知名称
object
通知对象,值为nil时表示所有
target
通知目标
action
目标动作,参数为通知对象
Return Value
监听者
-
单次监听通知,触发后自动移除监听
Declaration
Swift
public static func observeOnce( forName name: NSNotification.Name?, object: Any? = nil, queue: OperationQueue? = nil, using block: @escaping @Sendable (_ notification: Notification) -> Void )
Parameters
name
通知名称
object
通知对象,值为nil时表示所有
queue
通知队列
block
监听句柄
-
主线程安全单次监听通知,触发后自动移除监听
Declaration
Swift
public static func safeObserveOnce( forName name: NSNotification.Name?, object: Any? = nil, using block: @escaping @MainActor @Sendable (_ notification: Notification) -> Void )
Parameters
name
通知名称
object
通知对象,值为nil时表示所有
block
监听句柄
-
手工移除某个广播通知指定监听,可指定对象
Declaration
Swift
public func unobserveNotification(_ name: Notification.Name, object: AnyObject? = nil, target: AnyObject? = nil, action: Selector? = nil)
Parameters
name
通知名称
object
通知对象,值为nil时表示所有
target
通知目标
action
目标动作
-
手工移除某个指定对象广播通知指定监听
Declaration
Swift
@discardableResult public func unobserveNotification(observer: Any) -> Bool
Parameters
observer
监听者
-
手工移除所有点对点消息监听
Declaration
Swift
public func unobserveAllNotifications()
-
发送广播通知,附带对象和用户信息
Declaration
Swift
public func postNotification(_ name: Notification.Name, object: Any? = nil, userInfo: [AnyHashable : Any]? = nil)
Parameters
name
通知名称
object
通知对象
userInfo
用户信息
-
发送广播通知,附带对象和用户信息
Declaration
Swift
public static func postNotification(_ name: Notification.Name, object: Any? = nil, userInfo: [AnyHashable : Any]? = nil)
Parameters
name
通知名称
object
通知对象
userInfo
用户信息
-
监听对象某个属性KeyPath,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func observeProperty<Value>(_ keyPath: KeyPath<Base, Value>, options: NSKeyValueObservingOptions = [], block: @escaping @Sendable (Base, NSKeyValueObservedChange<Value>) -> Void) -> NSObjectProtocol
Parameters
keyPath
属性KeyPath
options
监听选项
block
目标句柄,block参数依次为object、change对象
Return Value
监听者
-
主线程安全监听对象某个属性KeyPath,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func safeObserveProperty<Value>(_ keyPath: KeyPath<Base, Value>, options: NSKeyValueObservingOptions = [], block: @escaping @MainActor @Sendable (Base, NSKeyValueObservedChange<Value>) -> Void) -> NSObjectProtocol where Base : Sendable, Value : Sendable
Parameters
keyPath
属性KeyPath
options
监听选项
block
目标句柄,block参数依次为object、change对象
Return Value
监听者
-
监听对象某个属性KeyPath,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func observeProperty<Value>(_ keyPath: KeyPath<Base, Value>, options: NSKeyValueObservingOptions = [], target: AnyObject?, action: Selector) -> NSObjectProtocol
Parameters
keyPath
属性KeyPath
options
监听选项
target
目标对象
action
目标动作,action参数依次为object、change对象
Return Value
监听者
-
主线程安全监听对象某个属性KeyPath,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func safeObserveProperty<Value>(_ keyPath: KeyPath<Base, Value>, options: NSKeyValueObservingOptions = [], target: AnyObject?, action: Selector) -> NSObjectProtocol
Parameters
keyPath
属性KeyPath
options
监听选项
target
目标对象
action
目标动作,action参数依次为object、change对象
Return Value
监听者
-
监听对象某个属性,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func observeProperty(_ property: String, block: @escaping @Sendable (Base, [NSKeyValueChangeKey : Any]) -> Void) -> NSObjectProtocol
Parameters
property
属性名称
block
目标句柄,block参数依次为object、优化的change字典(不含NSNull)
Return Value
监听者
-
主线程安全监听对象某个属性,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func safeObserveProperty(_ property: String, block: @escaping @MainActor @Sendable (Base, [NSKeyValueChangeKey : Any]) -> Void) -> NSObjectProtocol where Base : Sendable
Parameters
property
属性名称
block
目标句柄,block参数依次为object、优化的change字典(不含NSNull)
Return Value
监听者
-
监听对象某个属性,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func observeProperty(_ property: String, target: AnyObject?, action: Selector) -> NSObjectProtocol
Parameters
property
属性名称
target
目标对象
action
目标动作,action参数依次为object、优化的change字典(不含NSNull)
Return Value
监听者
-
主线程安全监听对象某个属性,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func safeObserveProperty(_ property: String, target: AnyObject?, action: Selector) -> NSObjectProtocol
Parameters
property
属性名称
target
目标对象
action
目标动作,action参数依次为object、优化的change字典(不含NSNull)
Return Value
监听者
-
手工移除某个属性指定KeyPath监听
Declaration
Swift
public func unobserveProperty<Value>(_ keyPath: KeyPath<Base, Value>, target: AnyObject? = nil, action: Selector? = nil)
Parameters
keyPath
属性KeyPath
target
目标对象,值为nil时移除所有对象(同UIControl)
action
目标动作,值为nil时移除所有动作(同UIControl)
-
手工移除某个属性指定监听
Declaration
Swift
public func unobserveProperty(_ property: String, target: AnyObject? = nil, action: Selector? = nil)
Parameters
property
属性名称
target
目标对象,值为nil时移除所有对象(同UIControl)
action
目标动作,值为nil时移除所有动作(同UIControl)
-
手工移除某个属性指定监听
Declaration
Swift
@discardableResult public func unobserveProperty(observer: Any) -> Bool
Parameters
observer
监听者
-
手工移除所有属性所有监听
Declaration
Swift
public func unobserveAllProperties()
-
手工添加指定KeyPath监听,对象释放时自动移除监听,添加多次执行多次
Declaration
Swift
@discardableResult public func addObservation(_ observation: NSKeyValueObservation, keyPath: AnyHashable? = nil, target: AnyObject? = nil, action: Selector? = nil) -> NSObjectProtocol
Parameters
observation
监听对象
keyPath
属性keyPath
target
目标对象
action
目标动作
Return Value
监听者
-
手工移除指定KeyPath监听
Declaration
Swift
@discardableResult public func removeObservation(_ observation: NSKeyValueObservation) -> Bool
Parameters
observation
监听对象
Return Value
是否移除成功
-
获取当前主window,可自定义
Declaration
Swift
@MainActor public static var main: UIWindow? { get set }
-
获取当前主场景,可自定义
Declaration
Swift
@MainActor public static var mainScene: UIWindowScene? { get set }
-
获取最顶部的视图控制器
Declaration
Swift
@MainActor public var topViewController: UIViewController? { get }
-
获取最顶部的导航栏控制器。如果顶部VC不含导航栏,返回nil
Declaration
Swift
@MainActor public var topNavigationController: UINavigationController? { get }
-
获取最顶部的显示控制器
Declaration
Swift
@MainActor public var topPresentedController: UIViewController? { get }
-
使用最顶部的导航栏控制器打开控制器
Declaration
Swift
@discardableResult @MainActor public func push(_ viewController: UIViewController, animated: Bool = true) -> Bool
-
使用最顶部的导航栏控制器打开控制器,同时pop指定数量控制器
Declaration
Swift
@discardableResult @MainActor public func push(_ viewController: UIViewController, pop count: Int, animated: Bool = true) -> Bool
-
使用最顶部的显示控制器弹出控制器,建议present导航栏控制器(可用来push)
Declaration
Swift
@MainActor public func present(_ viewController: UIViewController, animated: Bool = true, completion: (@MainActor @Sendable () -> Void)? = nil)
-
使用最顶部的视图控制器打开控制器,自动判断push|present
Declaration
Swift
@MainActor public func open(_ viewController: UIViewController, animated: Bool = true, options: NavigatorOptions = [], completion: (@MainActor @Sendable () -> Void)? = nil)
-
关闭最顶部的视图控制器,自动判断pop|dismiss,返回是否成功
Declaration
Swift
@discardableResult @MainActor public func close(animated: Bool = true, options: NavigatorOptions = [], completion: (@MainActor @Sendable () -> Void)? = nil) -> Bool
-
打开控制器。1.如果打开导航栏,则调用present;2.否则如果导航栏存在,则调用push;3.否则调用present
Declaration
Swift
@MainActor public func open(_ viewController: UIViewController, animated: Bool = true, options: NavigatorOptions = [], completion: (@MainActor @Sendable () -> Void)? = nil)
-
关闭控制器,返回是否成功。1.如果导航栏不存在,则调用dismiss;2.否则如果已是导航栏底部,则调用dismiss;3.否则调用pop
Declaration
Swift
@discardableResult @MainActor public func close(animated: Bool = true, options: NavigatorOptions = [], completion: (@MainActor @Sendable () -> Void)? = nil) -> Bool
-
自定义工作流名称,支持二级(“."分隔);默认返回小写类名(去掉ViewController、Controller)
Declaration
Swift
@MainActor public var workflowName: String { get set }
-
push新界面,完成时回调
Declaration
Swift
@MainActor public func pushViewController(_ viewController: UIViewController, animated: Bool, completion: (@MainActor @Sendable () -> Void)? = nil)
-
pop当前界面,完成时回调
Declaration
Swift
@discardableResult @MainActor public func popViewController(animated: Bool, completion: (@MainActor @Sendable () -> Void)? = nil) -> UIViewController?
-
pop到指定界面,完成时回调
Declaration
Swift
@discardableResult @MainActor public func popToViewController(_ viewController: UIViewController, animated: Bool, completion: (@MainActor @Sendable () -> Void)? = nil) -> [UIViewController]?
-
pop到根界面,完成时回调
Declaration
Swift
@discardableResult @MainActor public func popToRootViewController(animated: Bool, completion: (@MainActor @Sendable () -> Void)? = nil) -> [UIViewController]?
-
设置界面数组,完成时回调
Declaration
Swift
@MainActor public func setViewControllers(_ viewControllers: [UIViewController], animated: Bool, completion: (@MainActor @Sendable () -> Void)? = nil)
-
push新界面,同时pop指定数量界面,至少保留一个根控制器,完成时回调
Declaration
Swift
@MainActor public func pushViewController(_ viewController: UIViewController, pop count: Int, animated: Bool, completion: (@MainActor @Sendable () -> Void)? = nil)
-
pop指定数量界面,0不会pop,至少保留一个根控制器,完成时回调
Declaration
Swift
@discardableResult @MainActor public func popViewControllers(_ count: Int, animated: Bool, completion: (@MainActor @Sendable () -> Void)? = nil) -> [UIViewController]?
-
当前最外层工作流名称,即topViewController的工作流名称
Declaration
Swift
@MainActor public var topWorkflowName: String? { get }
-
push控制器,并清理最外层工作流(不属于工作流则不清理)
示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、(2、3)、4、(5、6)、9
Declaration
Swift
@MainActor public func push(_ viewController: UIViewController, popTopWorkflowAnimated animated: Bool, completion: (@MainActor @Sendable () -> Void)? = nil)
-
push控制器,并清理到指定工作流(不属于工作流则清理)
示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、(2、3)、9
Declaration
Swift
@MainActor public func push(_ viewController: UIViewController, popToWorkflow: String, animated: Bool, completion: (@MainActor @Sendable () -> Void)? = nil)
-
push控制器,并清理非根控制器(只保留根控制器)
示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、9
Declaration
Swift
@MainActor public func push(_ viewController: UIViewController, popToRootWorkflowAnimated animated: Bool, completion: (@MainActor @Sendable () -> Void)? = nil)
-
push控制器,并从外到内清理指定工作流,直到遇到不属于指定工作流的控制器停止
示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、(2、3)、4、9
Declaration
Swift
@MainActor public func push(_ viewController: UIViewController, popWorkflows workflows: [String]?, animated: Bool = true, completion: (@MainActor @Sendable () -> Void)? = nil)
-
pop方式清理最外层工作流,至少保留一个根控制器(不属于工作流则不清理)
示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、(2、3)、4、(5、6)
Declaration
Swift
@MainActor public func popTopWorkflow(animated: Bool = true, completion: (@MainActor @Sendable () -> Void)? = nil)
-
pop方式清理到指定工作流,至少保留一个根控制器(不属于工作流则清理)
示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、(2、3)
Declaration
Swift
@MainActor public func popToWorkflow(_ workflow: String, animated: Bool = true, completion: (@MainActor @Sendable () -> Void)? = nil)
-
pop方式从外到内清理指定工作流,直到遇到不属于指定工作流的控制器停止,至少保留一个根控制器
示例:1、(2、3)、4、(5、6)、(7、8),操作后为1、(2、3)、4
Declaration
Swift
@MainActor public func popWorkflows(_ workflows: [String]?, animated: Bool = true, completion: (@MainActor @Sendable () -> Void)? = nil)
-
获取当前类所在的模块名称,兼容主应用和framework等(可能不准确)
Declaration
Swift
public static var moduleName: String { get }
-
获取指定类所在的模块名称,兼容主应用和framework等(可能不准确)
Declaration
Swift
public static func moduleName(for aClass: AnyClass) -> String
-
获取任意对象的类型字符串,含模块名称
Declaration
Swift
public static func typeName(for object: Any) -> String
-
临时对象,强引用,线程安全,支持KVO
Declaration
Swift
public var tempObject: Any? { get set }
-
读取关联属性
Declaration
Swift
public func property(forName name: String) -> Any?
Parameters
name
属性名称
Return Value
属性值
-
读取Bool关联属性,默认false
Declaration
Swift
public func propertyBool(forName name: String) -> Bool
Parameters
name
属性名称
Return Value
属性值
-
读取Int关联属性,默认0
Declaration
Swift
public func propertyInt(forName name: String) -> Int
Parameters
name
属性名称
Return Value
属性值
-
读取Double关联属性,默认0
Declaration
Swift
public func propertyDouble(forName name: String) -> Double
Parameters
name
属性名称
Return Value
属性值
-
读取NSNumber关联属性,默认nil
Declaration
Swift
public func propertyNumber(forName name: String) -> NSNumber?
Parameters
name
属性名称
Return Value
属性值
-
设置关联属性,可指定关联策略,支持KVO
Declaration
Swift
public func setProperty(_ value: Any?, forName name: String, policy: objc_AssociationPolicy = .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
Parameters
value
属性值
name
属性名称
policy
关联策略,默认RETAIN_NONATOMIC
-
设置拷贝关联属性,支持KVO
Declaration
Swift
public func setPropertyCopy(_ value: Any?, forName name: String)
Parameters
value
属性值
name
属性名称
-
设置弱引用关联属性,支持KVO,OC不支持weak关联属性
Declaration
Swift
public func setPropertyWeak(_ value: AnyObject?, forName name: String)
Parameters
value
属性值
name
属性名称
-
设置Bool关联属性
Declaration
Swift
public func setPropertyBool(_ value: Bool, forName name: String)
Parameters
value
属性值
name
属性名称
-
设置Int关联属性
Declaration
Swift
public func setPropertyInt(_ value: Int, forName name: String)
Parameters
value
属性值
name
属性名称
-
设置Double关联属性
Declaration
Swift
public func setPropertyDouble(_ value: Double, forName name: String)
Parameters
value
属性值
name
属性名称
-
设置NSNumber关联属性
Declaration
Swift
public func setPropertyNumber(_ value: NSNumber?, forName name: String)
Parameters
value
属性值
name
属性名称
-
给对象绑定上另一个对象以供后续取出使用,如果 object 传入 nil 则会清除该 key 之前绑定的对象
Declaration
Swift
public func bindObject(_ object: Any?, forKey key: String)
Parameters
object
对象,会被 strong 强引用
forKey
键名
-
给对象绑定上另一个弱引用对象以供后续取出使用,如果 object 传入 nil 则会清除该 key 之前绑定的对象
Declaration
Swift
public func bindObjectWeak(_ object: AnyObject?, forKey key: String)
Parameters
object
对象,不会被 strong 强引用
forKey
键名
-
取出之前使用 bind 方法绑定的对象
Declaration
Swift
public func boundObject(forKey key: String) -> Any?
Parameters
forKey
键名
Return Value
绑定的对象
-
给对象绑定上一个 double 值以供后续取出使用
Declaration
Swift
public func bindDouble(_ value: Double, forKey: String)
Parameters
value
double值
forKey
键名
-
取出之前用 bindDouble:forKey: 绑定的值
Declaration
Swift
public func boundDouble(forKey: String) -> Double
Parameters
forKey
键名
Return Value
绑定的值
-
给对象绑定上一个 BOOL 值以供后续取出使用
Declaration
Swift
public func bindBool(_ value: Bool, forKey: String)
Parameters
value
布尔值
forKey
键名
-
取出之前用 bindBool:forKey: 绑定的值
Declaration
Swift
public func boundBool(forKey: String) -> Bool
Parameters
forKey
键名
Return Value
绑定的值
-
给对象绑定上一个 NSInteger 值以供后续取出使用
Declaration
Swift
public func bindInt(_ value: Int, forKey: String)
Parameters
value
整数值
forKey
键名
-
取出之前用 bindInt:forKey: 绑定的值
Declaration
Swift
public func boundInt(forKey: String) -> Int
Parameters
forKey
键名
Return Value
绑定的值
-
给对象绑定上一个 NSNumber 值以供后续取出使用
Declaration
Swift
public func bindNumber(_ value: NSNumber?, forKey: String)
Parameters
value
整数值
forKey
键名
-
取出之前用 bindNumber:forKey: 绑定的值
Declaration
Swift
public func boundNumber(forKey: String) -> NSNumber?
Parameters
forKey
键名
Return Value
绑定的值
-
移除之前使用 bind 方法绑定的对象
Declaration
Swift
public func removeBinding(forKey key: String)
Parameters
forKey
键名
-
移除之前使用 bind 方法绑定的所有对象
Declaration
Swift
public func removeAllBindings()
-
返回当前有绑定对象存在的所有的 key 的数组,数组中元素的顺序是随机的,如果不存在任何 key,则返回一个空数组
Declaration
Swift
public func allBindingKeys() -> [String]
-
返回是否设置了某个 key
Declaration
Swift
public func hasBindingKey(_ key: String) -> Bool
Parameters
key
键名
Return Value
是否绑定
-
获取当前对象的hashValue,等同于: ObjectIdentifier(base).hashValue
Declaration
Swift
public var hashValue: Int { get }
-
获取当前对象的反射字典(含父类直至NSObject),不含nil值
Declaration
Swift
public var mirrorDictionary: [String : Any] { get }
-
获取指定类的metaClass
Declaration
Swift
public static func metaClass(_ clazz: Any?) -> AnyClass?
Parameters
clazz
支持AnyClass|NSObject对象
Return Value
参数为AnyClass时,返回metaClass;参数为NSObject对象时,返回NSObject类
-
获取指定类的所有子类
Declaration
Swift
public static func allSubclasses(_ clazz: AnyClass) -> [AnyClass]
-
获取类方法列表(含父类直至NSObject),支持meta类(objc_getMetaClass)
Declaration
Swift
public static func classMethods(_ clazz: AnyClass) -> [String]
Parameters
clazz
指定类
Return Value
方法列表
-
获取类属性列表(含父类直至NSObject),支持meta类(objc_getMetaClass)
Declaration
Swift
public static func classProperties(_ clazz: AnyClass) -> [String]
Parameters
clazz
指定类
Return Value
属性列表
-
获取类Ivar列表(含父类直至NSObject),支持meta类(objc_getMetaClass)
Declaration
Swift
public static func classIvars(_ clazz: AnyClass) -> [String]
Parameters
clazz
指定类
Return Value
Ivar列表
-
读取关联对象,key为字符串,一般可使用#function
Declaration
Swift
public static func getAssociatedObject(_ object: Any, key: String) -> Any?
-
设置关联对象,key为字符串,一般可使用#function
Declaration
Swift
public static func setAssociatedObject(_ object: Any, key: String, value: Any?, policy: objc_AssociationPolicy = .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
-
安全调用内部属性获取方法,如果属性不存在,则忽略之
如果iOS13系统UIView调用部分valueForKey:方法闪退,且没有好的替代方案,可尝试调用此方法
Declaration
Swift
public func invokeGetter(_ name: String) -> Any?
Parameters
name
内部属性名称
Return Value
属性值
-
安全调用内部属性设置方法,如果属性不存在,则忽略之
如果iOS13系统UIView调用部分valueForKey:方法闪退,且没有好的替代方案,可尝试调用此方法
Declaration
Swift
public func invokeSetter(_ name: String, object: Any?)
Parameters
name
内部属性名称
object
传递的方法参数
-
安全调用方法,支持多个参数
Declaration
Swift
@discardableResult public func invokeMethod(_ selector: Selector, objects: [Any]? = nil) -> Unmanaged<AnyObject>!
Parameters
selector
要执行的方法
objects
传递的参数数组,默认空
Return Value
方法返回值
-
安全调用类方法,支持多个参数
Declaration
Swift
@discardableResult public static func invokeMethod(_ target: AnyObject, selector: Selector, objects: [Any]? = nil) -> Unmanaged<AnyObject>!
Parameters
target
调用的目标
selector
要执行的方法
objects
传递的参数数组,默认空
Return Value
方法返回值
-
安全获取当前对象的指定属性值(非keyPath)
Declaration
Swift
public func value(forKey key: String) -> Any?
-
安全设置当前对象的指定属性值(非keyPath)
Declaration
Swift
public func setValue(_ value: Any?, forKey key: String)
-
执行任意对象的反射属性句柄(含父类)
Declaration
Swift
public static func mirrorMap(_ object: Any, block: (String, Any) throws -> Void) rethrows
-
获取任意对象的反射字典(含父类直至NSObject),不含nil值
Declaration
Swift
public static func mirrorDictionary(_ object: Any?) -> [String : Any]
-
转换为UTF8字符串
Declaration
Swift
public var utf8String: String? { get }
-
安全字符串,不为nil
Declaration
Swift
public static func safeString(_ value: Any?) -> String
-
去掉首尾空白字符
Declaration
Swift
public var trimString: String { get }
-
首字母大写
Declaration
Swift
public var ucfirstString: String { get }
-
首字母小写
Declaration
Swift
public var lcfirstString: String { get }
-
驼峰转下划线
Declaration
Swift
public var underlineString: String { get }
-
下划线转驼峰
Declaration
Swift
public var camelString: String { get }
-
转换为UTF8数据
Declaration
Swift
public var utf8Data: Data? { get }
-
转换为URL
Declaration
Swift
public var url: URL? { get }
-
转换为文件URL
Declaration
Swift
public var fileURL: URL { get }
-
转换为NSNumber
Declaration
Swift
public var number: NSNumber? { get }
-
计算长度,中文为1,英文为0.5,表情为2
Declaration
Swift
public var unicodeLength: Int { get }
-
截取字符串,中文为1,英文为0.5,表情为2
Declaration
Swift
public func unicodeSubstring(_ length: Int) -> String
-
从指定位置截取子串
Declaration
Swift
public func substring(from index: Int) -> String
-
截取子串到指定位置
Declaration
Swift
public func substring(to index: Int) -> String
-
截取指定范围的子串
Declaration
Swift
public func substring(with range: NSRange) -> String
-
截取指定范围的子串
Declaration
Swift
public func substring(with range: Range<Int>) -> String
-
安全数字,不为nil
Declaration
Swift
public static func safeNumber(_ value: Any?) -> NSNumber
-
安全Int,不为nil
Declaration
Swift
public static func safeInt(_ value: Any?) -> Int
-
安全Bool,不为nil
Declaration
Swift
public static func safeBool(_ value: Any?) -> Bool
-
安全Float,不为nil
Declaration
Swift
public static func safeFloat(_ value: Any?) -> Float
-
安全Double,不为nil
Declaration
Swift
public static func safeDouble(_ value: Any?) -> Double
-
安全URL,不为nil,不兼容文件路径(需fileURLWithPath)
Declaration
Swift
public static func safeURL(_ value: Any?) -> URL
-
生成URL,中文自动URL编码
Declaration
Swift
public static func url(string: String?) -> URL?
-
生成URL,中文自动URL编码,支持基准URL
Declaration
Swift
public static func url(string: String?, relativeTo baseURL: URL?) -> URL?
-
交换类实例方法。复杂情况可能会冲突
Declaration
Swift
@discardableResult public static func exchangeInstanceMethod( _ originalClass: AnyClass, originalSelector: Selector, swizzleSelector: Selector ) -> Bool
Parameters
originalClass
目标类
originalSelector
原始方法
swizzleSelector
交换方法
Return Value
是否成功
-
交换类静态方法。复杂情况可能会冲突
Declaration
Swift
@discardableResult public static func exchangeClassMethod( _ originalClass: AnyClass, originalSelector: Selector, swizzleSelector: Selector ) -> Bool
Parameters
originalClass
目标类
originalSelector
原始方法
swizzleSelector
交换方法
Return Value
是否成功
-
交换类实例方法为block实现。复杂情况可能会冲突
swizzleBlock示例:
^(__unsafe_unretained UIViewController *selfObject, BOOL animated){ ((void(*)(id, SEL, BOOL))objc_msgSend)(selfObject, swizzleSelector, animated); }
Declaration
Swift
@discardableResult public static func exchangeInstanceMethod( _ originalClass: AnyClass, originalSelector: Selector, swizzleSelector: Selector, block: Any ) -> Bool
Parameters
originalClass
目标类
originalSelector
原始方法
swizzleSelector
交换方法
block
实现block
Return Value
是否成功
-
交换类静态方法为block实现。复杂情况可能会冲突
Declaration
Swift
@discardableResult public static func exchangeClassMethod( _ originalClass: AnyClass, originalSelector: Selector, swizzleSelector: Selector, block: Any ) -> Bool
Parameters
originalClass
目标类
originalSelector
原始方法
swizzleSelector
交换方法
block
实现block
Return Value
是否成功
-
生成原始方法对应的随机交换方法
Declaration
Swift
public static func exchangeSwizzleSelector( _ selector: Selector ) -> Selector
Parameters
selector
原始方法
Return Value
交换方法
-
通用swizzle替换方法为block实现,支持类和对象,identifier有值且相同时仅执行一次。复杂情况不会冲突,推荐使用
Swift实现代码示例:
NSObject.fw.swizzleMethod( UIViewController.self, selector: #selector(UIViewController.viewDidLoad) ) { (store: SwizzleStore <@convention(c) (UIViewController, Selector) -> Void, @convention(block) (UIViewController) -> Void>) in { store.original($0, store.selector) // ... }}
Declaration
Swift
@discardableResult public static func swizzleMethod<MethodSignature, SwizzleSignature>( _ target: Any?, selector: Selector, identifier: String? = nil, methodSignature: MethodSignature.Type = MethodSignature.self, swizzleSignature: SwizzleSignature.Type = SwizzleSignature.self, block: @escaping (SwizzleStore<MethodSignature, SwizzleSignature>) -> SwizzleSignature ) -> Bool
Parameters
target
目标类或对象
selector
原始方法
identifier
唯一标识,有值且相同时仅执行一次,默认nil
methodSignature
原始方法签名,示例:(@convention© (AnyObject, Selector) -> String).self
swizzleSignature
交换方法签名,示例:(@convention(block) (AnyObject) -> String).self
block
实现句柄,示例:{ store in { selfObject in return store.original(selfObject, store.selector) } }
Return Value
是否成功
-
使用swizzle替换类实例方法为block实现,identifier有值且相同时仅执行一次。复杂情况不会冲突,推荐使用
Swift实现代码示例:
NSObject.fw.swizzleInstanceMethod( UIViewController.self, selector: #selector(UIViewController.viewDidLoad), methodSignature: (@convention(c) (UIViewController, Selector) -> Void).self, swizzleSignature: (@convention(block) (UIViewController) -> Void).self ) { store in { selfObject in store.original(selfObject, store.selector) // ... }}
Declaration
Swift
@discardableResult public static func swizzleInstanceMethod<MethodSignature, SwizzleSignature>( _ originalClass: AnyClass, selector: Selector, identifier: String? = nil, methodSignature: MethodSignature.Type = MethodSignature.self, swizzleSignature: SwizzleSignature.Type = SwizzleSignature.self, block: @escaping (SwizzleStore<MethodSignature, SwizzleSignature>) -> SwizzleSignature ) -> Bool
Parameters
originalClass
原始类
selector
原始方法
identifier
唯一标识,默认nil
methodSignature
原始方法签名,示例:(@convention© (AnyObject, Selector) -> String).self
swizzleSignature
交换方法签名,示例:(@convention(block) (AnyObject) -> String).self
block
实现句柄,示例:{ store in { selfObject in return store.original(selfObject, store.selector) } }
Return Value
是否成功
-
使用swizzle替换类静态方法为block实现,identifier有值且相同时仅执行一次。复杂情况不会冲突,推荐使用
Declaration
Swift
@discardableResult public static func swizzleClassMethod<MethodSignature, SwizzleSignature>( _ originalClass: AnyClass, selector: Selector, identifier: String? = nil, methodSignature: MethodSignature.Type = MethodSignature.self, swizzleSignature: SwizzleSignature.Type = SwizzleSignature.self, block: @escaping (SwizzleStore<MethodSignature, SwizzleSignature>) -> SwizzleSignature ) -> Bool
Parameters
originalClass
原始类
selector
原始方法
identifier
唯一标识,默认nil
methodSignature
原始方法签名,示例:(@convention© (AnyObject, Selector) -> String).self
swizzleSignature
交换方法签名,示例:(@convention(block) (AnyObject) -> String).self
block
实现句柄,示例:{ store in { selfObject in return store.original(selfObject, store.selector) } }
Return Value
是否成功
-
使用swizzle替换对象实例方法为block实现,identifier相同时仅执行一次。结合isSwizzleInstanceMethod使用
Declaration
Swift
@discardableResult public func swizzleInstanceMethod<MethodSignature, SwizzleSignature>( _ originalSelector: Selector, identifier: String = "", methodSignature: MethodSignature.Type = MethodSignature.self, swizzleSignature: SwizzleSignature.Type = SwizzleSignature.self, block: @escaping (SwizzleStore<MethodSignature, SwizzleSignature>) -> SwizzleSignature ) -> Bool
Parameters
originalSelector
原始方法
identifier
唯一标识,默认空字符串
methodSignature
原始方法签名,示例:(@convention© (AnyObject, Selector) -> String).self
swizzleSignature
交换方法签名,示例:(@convention(block) (AnyObject) -> String).self
block
实现句柄,示例:{ store in { selfObject in return store.original(selfObject, store.selector) } }
Return Value
是否成功
-
通用swizzle替换方法为block实现,支持类和对象,identifier有值且相同时仅执行一次。复杂情况不会冲突,推荐使用
Swift实现代码示例:
NSObject.fw.swizzleInstanceMethod(UIViewController.self, selector: NSSelectorFromString("viewDidLoad")) { targetClass, originalCMD, originalIMP in let swizzleIMP: @convention(block)(UIViewController) -> Void = { selfObject in let originalMSG = unsafeBitCast(originalIMP(), to: (@convention(c)(UIViewController, Selector) -> Void).self) originalMSG(selfObject, originalCMD) // ... } return unsafeBitCast(swizzleIMP, to: AnyObject.self) }
Declaration
Swift
@discardableResult public static func swizzleMethod( _ target: Any?, selector: Selector, identifier: String? = nil, block: @escaping (AnyClass, Selector, @escaping () -> IMP) -> Any ) -> Bool
Parameters
target
目标类或对象
selector
原始方法
identifier
唯一标识,有值且相同时仅执行一次,默认nil
block
实现句柄
Return Value
是否成功
-
使用swizzle替换类实例方法为block实现,identifier有值且相同时仅执行一次。复杂情况不会冲突,推荐使用
Swift实现代码示例:
NSObject.fw.swizzleInstanceMethod(UIViewController.self, selector: NSSelectorFromString("viewDidLoad")) { targetClass, originalCMD, originalIMP in let swizzleIMP: @convention(block)(UIViewController) -> Void = { selfObject in let originalMSG = unsafeBitCast(originalIMP(), to: (@convention(c)(UIViewController, Selector) -> Void).self) originalMSG(selfObject, originalCMD) // ... } return unsafeBitCast(swizzleIMP, to: AnyObject.self) }
Declaration
Swift
@discardableResult public static func swizzleInstanceMethod( _ originalClass: AnyClass, selector: Selector, identifier: String? = nil, block: @escaping (AnyClass, Selector, @escaping () -> IMP) -> Any ) -> Bool
Parameters
originalClass
原始类
selector
原始方法
identifier
唯一标识,默认nil
block
实现句柄
Return Value
是否成功
-
使用swizzle替换类静态方法为block实现,identifier有值且相同时仅执行一次。复杂情况不会冲突,推荐使用
Declaration
Swift
@discardableResult public static func swizzleClassMethod( _ originalClass: AnyClass, selector: Selector, identifier: String? = nil, block: @escaping (AnyClass, Selector, @escaping () -> IMP) -> Any ) -> Bool
Parameters
originalClass
原始类
selector
原始方法
identifier
唯一标识,默认nil
block
实现句柄
Return Value
是否成功
-
使用swizzle替换对象实例方法为block实现,identifier相同时仅执行一次。结合isSwizzleInstanceMethod使用
Declaration
Swift
@discardableResult public func swizzleInstanceMethod( _ originalSelector: Selector, identifier: String = "", block: @escaping (AnyClass, Selector, @escaping () -> IMP) -> Any ) -> Bool
Parameters
originalSelector
原始方法
identifier
唯一标识,默认空字符串
block
实现句柄
Return Value
是否成功
-
判断对象是否使用swizzle替换过指定identifier实例方法。结合swizzleInstanceMethod使用
因为实际替换的是类方法,为了防止影响该类其它对象,需先判断该对象是否替换过,仅替换过才执行自定义流程
Declaration
Swift
public func isSwizzleInstanceMethod( _ originalSelector: Selector, identifier: String = "" ) -> Bool
Parameters
originalSelector
原始方法
identifier
唯一标识,默认空字符串
Return Value
是否替换
-
主线程安全异步执行句柄
Declaration
Swift
public static func mainAsync(execute block: @escaping @MainActor @Sendable () -> Void)
-
当主线程时执行句柄,非主线程不执行
Declaration
Swift
public static func mainSyncIf(execute block: @MainActor () -> Void)
-
当主线程时执行句柄,非主线程执行另一个句柄
Declaration
Swift
public static func mainSyncIf<T>(execute block: @MainActor () -> T, otherwise: () -> T) -> T where T : Sendable
-
主现成安全异步执行deinit句柄
Declaration
Swift
public static func mainDeinit(execute block: @escaping @MainActor @Sendable () -> Void)
-
主现成安全异步执行deinit句柄,可携带参数(非释放对象)
Declaration
Swift
public static func mainDeinit<T>(object: T, execute block: @escaping @MainActor @Sendable (T) -> Void) where T : Sendable
-
自定义转场过程中containerView的背景色,默认透明
Declaration
Swift
@MainActor public var containerBackgroundColor: UIColor! { get set }
-
全局启用NavigationBar转场。启用后各个ViewController管理自己的导航栏样式,在viewDidLoad或viewViewAppear中设置即可
Declaration
Swift
@MainActor public static func enableBarTransition()
-
是否启用导航栏全屏返回手势,默认NO。启用时系统返回手势失效,禁用时还原系统手势。如果只禁用系统手势,设置interactivePopGestureRecognizer.enabled即可
Declaration
Swift
@MainActor public var fullscreenPopGestureEnabled: Bool { get set }
-
导航栏全屏返回手势对象
Declaration
Swift
@MainActor public var fullscreenPopGestureRecognizer: UIPanGestureRecognizer { get }
-
判断手势是否是全局返回手势对象
Declaration
Swift
@MainActor public static func isFullscreenPopGestureRecognizer(_ gestureRecognizer: UIGestureRecognizer) -> Bool
-
转场动画自定义判断标识,不相等才会启用转场。默认nil启用转场。可重写或者push前设置生效
Declaration
Swift
@MainActor public var barTransitionIdentifier: AnyHashable? { get set }
-
视图控制器是否禁用全屏返回手势,默认NO
Declaration
Swift
@MainActor public var fullscreenPopGestureDisabled: Bool { get set }
-
视图控制器全屏手势距离左侧最大距离,默认0,无限制
Declaration
Swift
@MainActor public var fullscreenPopGestureDistance: CGFloat { get set }
-
导航栏背景视图,显示背景色和背景图片等
Declaration
Swift
@MainActor public var backgroundView: UIView? { get }
-
导航栏内容视图,iOS11+才存在,显示item和titleView等
Declaration
Swift
@MainActor public var contentView: UIView? { get }
-
导航栏大标题视图,显示时才有值。如果要设置背景色,可使用backgroundView.backgroundColor
Declaration
Swift
@MainActor public var largeTitleView: UIView? { get }
-
导航栏大标题高度,与是否隐藏无关
Declaration
Swift
@MainActor public static var largeTitleHeight: CGFloat { get }
-
工具栏背景视图,显示背景色和背景图片等。如果标签栏同时显示,背景视图高度也会包含标签栏高度
Declaration
Swift
@MainActor public var backgroundView: UIView? { get }
-
工具栏内容视图,iOS11+才存在,显示item等
Declaration
Swift
@MainActor public var contentView: UIView? { get }
-
显示右上角提醒灯,上右偏移指定距离(正外负内)
Declaration
Swift
@MainActor public func showBadgeView(_ badgeView: BadgeView, badgeValue: String? = nil)
-
隐藏提醒灯
Declaration
Swift
@MainActor public func hideBadgeView()
-
获取UIBarItem(UIBarButtonItem、UITabBarItem)内部的view,通常对于navigationItem和tabBarItem而言,需要在设置为item后并且在bar可见时(例如 viewDidAppear:及之后)获取fwView才有值
Declaration
Swift
@MainActor public weak var view: UIView? { get }
-
当item内的view生成后就会调用一次这个block,仅对UIBarButtonItem、UITabBarItem有效
Declaration
Swift
@MainActor public var viewLoadedBlock: ((Base, UIView) -> Void)? { get set }
-
显示右上角提醒灯,上右偏移指定距离(正外负内)
Declaration
Swift
@MainActor public func showBadgeView(_ badgeView: BadgeView, badgeValue: String? = nil)
-
隐藏提醒灯
Declaration
Swift
@MainActor public func hideBadgeView()
-
获取一个UITabBarItem内显示图标的UIImageView,如果找不到则返回nil
Declaration
Swift
@MainActor public weak var imageView: UIImageView? { get }
-
显示右上角提醒灯,上右偏移指定距离(正外负内)
Declaration
Swift
@MainActor public func showBadgeView(_ badgeView: BadgeView, badgeValue: String? = nil)
-
隐藏提醒灯
Declaration
Swift
@MainActor public func hideBadgeView()
-
集合视图代理,延迟加载
Declaration
Swift
@MainActor public var collectionDelegate: CollectionViewDelegate { get set }
-
快速创建collectionView
Declaration
Swift
@MainActor public static func collectionView() -> Base
-
快速创建collectionView,自定义collectionViewLayout
Declaration
Swift
@MainActor public static func collectionView(_ collectionViewLayout: UICollectionViewLayout) -> Base
-
初始化布局section配置,在prepareLayout调用即可
Declaration
Swift
@MainActor public func sectionConfigPrepareLayout()
-
获取布局section属性,在layoutAttributesForElementsInRect:调用并添加即可
Declaration
Swift
@MainActor public func sectionConfigLayoutAttributes(forElementsIn rect: CGRect) -> [UICollectionViewLayoutAttributes]
-
抽屉拖拽视图,绑定抽屉拖拽效果后才存在
Declaration
Swift
@MainActor public var drawerView: DrawerView? { get set }
-
设置抽屉拖拽效果。如果view为滚动视图,自动处理与滚动视图pan手势冲突的问题
@param direction 拖拽方向,如向上拖动视图时为Up,默认向上 @param positions 抽屉位置,至少两级,相对于view父视图的originY位置 @param kickbackHeight 回弹高度,拖拽小于该高度执行回弹 @param positionChanged 抽屉视图位移回调,参数为相对父视图的origin位置和是否拖拽完成的标记 @return 抽屉拖拽视图
Declaration
Swift
@discardableResult @MainActor public func drawerView( _ direction: UISwipeGestureRecognizer.Direction, positions: [CGFloat], kickbackHeight: CGFloat, positionChanged: (@MainActor @Sendable (CGFloat, Bool) -> Void)? = nil ) -> DrawerView
-
外部滚动视图是否位于顶部固定位置,在顶部时不能滚动
Declaration
Swift
@MainActor public var drawerSuperviewFixed: Bool { get set }
-
外部滚动视图scrollViewDidScroll调用,参数为固定的位置
Declaration
Swift
@MainActor public func drawerSuperviewDidScroll(_ position: CGFloat)
-
内嵌滚动视图scrollViewDidScroll调用,参数为外部滚动视图
Declaration
Swift
@MainActor public func drawerSubviewDidScroll(_ superview: UIScrollView)
-
视图持有者对象,弱引用
Declaration
Swift
@MainActor public weak var viewHolder: NSObject? { get set }
-
重用唯一标志,默认nil
Declaration
Swift
@MainActor public var reuseIdentifier: String? { get set }
-
视图已重用次数,默认0
Declaration
Swift
@MainActor public var reusedTimes: Int { get set }
-
标记重用准备中(true),准备中的视图在完成(false)之前都不会被dequeue,默认false
Declaration
Swift
@MainActor public var reusePreparing: Bool { get set }
-
标记重用失效,将自动从缓存池移除
Declaration
Swift
@MainActor public var reuseInvalid: Bool { get set }
-
按需预加载下一个可重用视图,仅当前视图可重用时生效
Declaration
Swift
@MainActor public func preloadReusableView()
-
表格代理,延迟加载
Declaration
Swift
@MainActor public var tableDelegate: TableViewDelegate { get set }
-
快速创建tableView,可配置钩子句柄
Declaration
Swift
@MainActor public static func tableView(_ style: UITableView.Style = .plain) -> Base
-
配置创建tableView钩子句柄,默认nil
Declaration
Swift
@MainActor public static var tableViewConfiguration: ((Base) -> Void)? { get set }
-
滚动事件代理,需手工设置delegate生效
Declaration
Swift
@MainActor public var scrollDelegate: ScrollViewDelegate { get set }
-
输入事件代理,需手工设置delegate生效
Declaration
Swift
@MainActor public var textDelegate: TextFieldDelegate { get set }
-
输入事件代理,需手工设置delegate生效
Declaration
Swift
@MainActor public var textDelegate: TextViewDelegate { get set }
-
搜索栏事件代理,需手工设置delegate生效
Declaration
Swift
@MainActor public var searchDelegate: SearchBarDelegate { get set }
-
视图控制器present|dismiss转场。注意会修改transitioningDelegate,且会强引用之;如需weak引用,请直接设置transitioningDelegate
Declaration
Swift
@MainActor public var modalTransition: AnimatedTransition? { get set }
-
视图控制器push|pop转场,代理导航控制器转场,需在fwNavigationTransition设置后生效
Declaration
Swift
@MainActor public var viewTransition: AnimatedTransition? { get set }
-
自定义控制器present系统转场(蒙层渐变,内容默认向上动画),会设置fwModalTransition
Declaration
Swift
@discardableResult @MainActor public func setPresentTransition(_ presentationBlock: (@MainActor @Sendable (PresentationController) -> Void)? = nil, edge: UIRectEdge = .bottom) -> AnimatedTransition
-
自定义控制器alert缩放转场(蒙层渐变,内容缩放动画),会设置fwModalTransition
Declaration
Swift
@discardableResult @MainActor public func setAlertTransition(_ presentationBlock: (@MainActor @Sendable (PresentationController) -> Void)? = nil) -> AnimatedTransition
-
自定义控制器fade渐变转场(蒙层和内容渐变动画),会设置fwModalTransition;
Declaration
Swift
@discardableResult @MainActor public func setFadeTransition(_ presentationBlock: (@MainActor @Sendable (PresentationController) -> Void)? = nil) -> AnimatedTransition
-
设置iOS13默认present手势下拉dismiss时的回调block,仅iOS13生效,自动触发,手工dismiss不会触发。会自动设置presentationController.delegate
Declaration
Swift
@MainActor public var presentationDidDismiss: (() -> Void)? { get set }
-
自定义控制器popover弹出效果(preferredContentSize设置大小),会自动设置modalPresentationStyle和popoverPresentationController.delegate
Declaration
Swift
@MainActor public func setPopoverPresentation(_ presentationBlock: (@MainActor @Sendable (UIPopoverPresentationController) -> Void)?, shouldDismiss: Bool)
-
转场添加到指定控制器(pinEdges占满父视图),返回父容器视图。默认inAncestorView开启时查找顺序:VC.tabBarController.view > VC.navigationController.view > VC.view
Declaration
Swift
@discardableResult @MainActor public func transition(to viewController: UIViewController, inAncestorView: Bool = true, pinEdges aPinEdges: Bool = true) -> UIView
-
包装到转场控制器(pinEdges占满父视图),返回创建的控制器
Declaration
Swift
@MainActor public func wrappedTransitionController(_ aPinEdges: Bool = true) -> UIViewController
-
自定义视图模拟present系统转场(蒙层渐变,内容默认向上动画)
Declaration
Swift
@MainActor public func setPresentTransition(_ transitionType: AnimatedTransitionType, contentView: UIView?, edge: UIRectEdge = .bottom, completion: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
自定义视图模拟alert缩放转场(蒙层渐变,内容缩放动画)
Declaration
Swift
@MainActor public func setAlertTransition(_ transitionType: AnimatedTransitionType, completion: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
自定义视图模拟fade渐变转场(蒙层和内容渐变动画)
Declaration
Swift
@MainActor public func setFadeTransition(_ transitionType: AnimatedTransitionType, completion: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
导航控制器push|pop转场。注意会修改delegate,且会强引用之,一直生效直到设置为nil。如需weak引用,请直接设置delegate
Declaration
Swift
@MainActor public var navigationTransition: AnimatedTransition? { get set }
-
重用WebView全局配置句柄(第二个参数为重用标志),为所有复用WebView提供预先的默认configuration
Declaration
Swift
@MainActor public static var reuseConfigurationBlock: ((WKWebViewConfiguration, String) -> Void)? { get set }
-
默认跨WKWebView共享Cookie,切换用户时可重置processPool清空Cookie
Declaration
Swift
@MainActor public static var processPool: WKProcessPool { get set }
-
快捷创建WKWebView默认配置,自动初始化User-Agent和共享processPool
Declaration
Swift
@MainActor public static func defaultConfiguration() -> WKWebViewConfiguration
-
获取默认浏览器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
@MainActor public static var browserUserAgent: String { get }
-
获取默认浏览器扩展UserAgent,不含平台信息,可用于applicationNameForUserAgent,示例:Mobile/15E148 Safari/605.1.15 Example/1.0.0
Declaration
Swift
@MainActor public static var extensionUserAgent: String { get }
-
获取默认请求UserAgent,可用于网络请求,示例:Example/1.0.0 (site.wuyong.Example; iPhone15,1; iOS 14.2) FWFramework/6.0.0
Declaration
Swift
public nonisolated static var requestUserAgent: String { get }
-
获取当前UserAgent,未自定义时为默认,示例:Mozilla/5.0 (iPhone; CPU OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
Declaration
Swift
@MainActor public var userAgent: String { get }
-
加载网页请求,支持String|URL|URLRequest等
Declaration
Swift
@discardableResult @MainActor public func loadRequest(_ request: Any?) -> WKNavigation?
-
清空网页缓存,完成后回调。单个网页请求指定URLRequest.cachePolicy即可
Declaration
Swift
@MainActor public static func clearCache(_ completion: (@MainActor @Sendable () -> Void)? = nil)
-
清空WebView后退和前进的网页栈
Declaration
Swift
@MainActor public func clearBackForwardList()
-
使用JavaScriptCore执行脚本并返回结果,支持模板替换。常用语服务端下发计算公式等场景
Declaration
Swift
public nonisolated static func evaluateScript(_ script: String, variables: [String : String] = [:]) -> JSValue?
-
设置Javascript桥接器强引用属性,防止使用过程中被释放
Declaration
Swift
@MainActor public var jsBridge: WebViewJSBridge? { get set }
-
是否启用Javascript桥接器,需结合setupJsBridge使用
Declaration
Swift
@MainActor public var jsBridgeEnabled: Bool { get set }
-
自动初始化Javascript桥接器,jsBridgeEnabled开启时生效
Declaration
Swift
@discardableResult @MainActor public func setupJsBridge() -> WebViewJSBridge?
-
绑定控制器导航栏左侧按钮组,需结合setupNavigationItems使用
Declaration
Swift
@MainActor public var navigationItems: [Any]? { get set }
-
自动初始化控制器导航栏左侧按钮组,navigationItems设置后生效
Declaration
Swift
@MainActor public func setupNavigationItems(_ viewController: UIViewController)
-
设置Web加载进度,0和1自动切换隐藏。可设置trackTintColor为clear,隐藏背景色
Declaration
Swift
@MainActor public var webProgress: Float { get set }
-
自定义弹窗插件,未设置时自动从插件池加载
Declaration
Swift
@MainActor public var alertPlugin: AlertPlugin! { get set }
-
显示错误警告框
Declaration
Swift
@MainActor public func showAlert( error: Error?, cancel: AttributedStringParameter? = nil, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
error
错误对象
cancel
取消按钮标题,默认关闭
cancelBlock
取消按钮事件
-
显示警告框(简单版)
Declaration
Swift
@MainActor public func showAlert( title: AttributedStringParameter?, message: AttributedStringParameter?, style: AlertStyle = .default, cancel: AttributedStringParameter? = nil, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
警告框标题
message
警告框消息
style
警告框样式
cancel
取消按钮标题,默认关闭
cancelBlock
取消按钮事件
-
显示警告框(详细版)
Declaration
Swift
@MainActor public func showAlert( title: AttributedStringParameter?, message: AttributedStringParameter?, style: AlertStyle = .default, cancel: AttributedStringParameter?, actions: [AttributedStringParameter]?, actionBlock: (@MainActor @Sendable (Int) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
警告框标题
message
警告框消息
style
警告框样式
cancel
取消按钮标题,默认单按钮关闭,多按钮取消
actions
动作按钮标题列表
actionBlock
动作按钮点击事件,参数为索引index
cancelBlock
取消按钮事件
-
显示确认框(简单版)
Declaration
Swift
@MainActor public func showConfirm( title: AttributedStringParameter?, message: AttributedStringParameter?, confirmBlock: (@MainActor @Sendable () -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
确认框标题
message
确认框消息
confirmBlock
确认按钮事件
cancelBlock
取消按钮事件
-
显示确认框(详细版)
Declaration
Swift
@MainActor public func showConfirm( title: AttributedStringParameter?, message: AttributedStringParameter?, cancel: AttributedStringParameter?, confirm: AttributedStringParameter?, confirmBlock: (@MainActor @Sendable () -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
确认框标题
message
确认框消息
cancel
取消按钮文字,默认取消
confirm
确认按钮文字,默认确定
confirmBlock
确认按钮事件
cancelBlock
取消按钮事件
-
显示输入框(简单版)
Declaration
Swift
@MainActor public func showPrompt( title: AttributedStringParameter?, message: AttributedStringParameter?, cancel: AttributedStringParameter? = nil, confirm: AttributedStringParameter? = nil, promptBlock: (@MainActor @Sendable (UITextField) -> Void)? = nil, confirmBlock: (@MainActor @Sendable (String) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
输入框标题
message
输入框消息
cancel
取消按钮文字,默认取消
confirm
确认按钮文字,默认确定
promptBlock
输入框初始化事件,参数为输入框
confirmBlock
确认按钮事件,参数为输入值
cancelBlock
取消按钮事件
-
显示输入框(详细版)
Declaration
Swift
@MainActor public func showPrompt( title: AttributedStringParameter?, message: AttributedStringParameter?, cancel: AttributedStringParameter? = nil, confirm: AttributedStringParameter? = nil, promptCount: Int, promptBlock: (@MainActor @Sendable (UITextField, Int) -> Void)?, confirmBlock: (@MainActor @Sendable ([String]) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
输入框标题
message
输入框消息
cancel
取消按钮文字,默认取消
confirm
确认按钮文字,默认确定
promptCount
输入框数量
promptBlock
输入框初始化事件,参数为输入框和索引index
confirmBlock
确认按钮事件,参数为输入值数组
cancelBlock
取消按钮事件
-
showAlert(title:
message: style: cancel: actions: promptCount: promptBlock: actionBlock: cancelBlock: customBlock: ) 显示弹出框(完整版)
Declaration
Swift
@MainActor public func showAlert( title: AttributedStringParameter?, message: AttributedStringParameter?, style: AlertStyle = .default, cancel: AttributedStringParameter?, actions: [AttributedStringParameter]?, promptCount: Int = 0, promptBlock: (@MainActor @Sendable (UITextField, Int) -> Void)? = nil, actionBlock: (@MainActor @Sendable ([String], Int) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)?, customBlock: (@MainActor @Sendable (Any) -> Void)? )
Parameters
title
弹出框标题
message
弹出框消息
style
警告框样式
cancel
取消按钮标题,默认Alert单按钮关闭,Alert多按钮或Sheet取消
actions
动作按钮标题列表
promptCount
输入框数量,默认0
promptBlock
输入框初始化事件,参数为输入框和索引index,默认nil
actionBlock
动作按钮点击事件,参数为输入值数组和索引index
cancelBlock
取消按钮事件
customBlock
自定义弹出框事件
-
显示操作表(无动作)
Declaration
Swift
@MainActor public func showSheet( title: AttributedStringParameter?, message: AttributedStringParameter?, cancel: AttributedStringParameter?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
操作表标题
message
操作表消息
cancel
取消按钮标题,默认取消
cancelBlock
取消按钮事件
-
显示操作表(简单版)
Declaration
Swift
@MainActor public func showSheet( title: AttributedStringParameter?, message: AttributedStringParameter?, actions: [AttributedStringParameter]?, actionBlock: (@MainActor @Sendable (Int) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
操作表标题
message
操作表消息
actions
动作按钮标题列表
actionBlock
动作按钮点击事件,参数为索引index
cancelBlock
取消按钮事件
-
显示操作表(详细版)
Declaration
Swift
@MainActor public func showSheet( title: AttributedStringParameter?, message: AttributedStringParameter?, cancel: AttributedStringParameter?, actions: [AttributedStringParameter]?, currentIndex: Int = -1, actionBlock: (@MainActor @Sendable (Int) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
操作表标题
message
操作表消息
cancel
取消按钮标题,默认取消
actions
动作按钮标题列表
currentIndex
当前选中动作索引,默认-1
actionBlock
动作按钮点击事件,参数为索引index
cancelBlock
取消按钮事件
-
显示操作表(完整版)
Declaration
Swift
@MainActor public func showSheet( title: AttributedStringParameter?, message: AttributedStringParameter?, cancel: AttributedStringParameter?, actions: [AttributedStringParameter]?, currentIndex: Int = -1, actionBlock: (@MainActor @Sendable (Int) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)?, customBlock: (@MainActor @Sendable (Any) -> Void)? )
Parameters
title
操作表标题
message
操作表消息
cancel
取消按钮标题,默认Alert单按钮关闭,Alert多按钮或Sheet取消
actions
动作按钮标题列表
currentIndex
当前选中动作索引,默认-1
actionBlock
动作按钮点击事件,参数为输入值数组和索引index
cancelBlock
取消按钮事件
customBlock
自定义弹出框事件
-
手工隐藏弹出框,完成后回调。当animated为false时如需获取最新控制器等,也需在异步completion中处理
Declaration
Swift
@MainActor public func hideAlert( animated: Bool, completion: (@MainActor @Sendable () -> Void)? = nil )
Parameters
animated
是否执行动画
completion
完成异步回调
-
判断是否正在显示弹出框
Declaration
Swift
@MainActor public var isShowingAlert: Bool { get }
-
显示错误警告框
Declaration
Swift
@MainActor public func showAlert( error: Error?, cancel: AttributedStringParameter? = nil, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
error
错误对象
cancel
取消按钮标题,默认关闭
cancelBlock
取消按钮事件
-
显示警告框(简单版)
Declaration
Swift
@MainActor public func showAlert( title: AttributedStringParameter?, message: AttributedStringParameter?, style: AlertStyle = .default, cancel: AttributedStringParameter? = nil, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
警告框标题
message
警告框消息
style
警告框样式
cancel
取消按钮标题,默认关闭
cancelBlock
取消按钮事件
-
显示警告框(详细版)
Declaration
Swift
@MainActor public func showAlert( title: AttributedStringParameter?, message: AttributedStringParameter?, style: AlertStyle = .default, cancel: AttributedStringParameter?, actions: [AttributedStringParameter]?, actionBlock: (@MainActor @Sendable (Int) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
警告框标题
message
警告框消息
style
警告框样式
cancel
取消按钮标题,默认单按钮关闭,多按钮取消
actions
动作按钮标题列表
actionBlock
动作按钮点击事件,参数为索引index
cancelBlock
取消按钮事件
-
显示确认框(简单版)
Declaration
Swift
@MainActor public func showConfirm( title: AttributedStringParameter?, message: AttributedStringParameter?, confirmBlock: (@MainActor @Sendable () -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
确认框标题
message
确认框消息
confirmBlock
确认按钮事件
cancelBlock
取消按钮事件
-
显示确认框(详细版)
Declaration
Swift
@MainActor public func showConfirm( title: AttributedStringParameter?, message: AttributedStringParameter?, cancel: AttributedStringParameter?, confirm: AttributedStringParameter?, confirmBlock: (@MainActor @Sendable () -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
确认框标题
message
确认框消息
cancel
取消按钮文字,默认取消
confirm
确认按钮文字,默认确定
confirmBlock
确认按钮事件
cancelBlock
取消按钮事件
-
显示输入框(简单版)
Declaration
Swift
@MainActor public func showPrompt( title: AttributedStringParameter?, message: AttributedStringParameter?, cancel: AttributedStringParameter?, confirm: AttributedStringParameter?, promptBlock: (@MainActor @Sendable (UITextField) -> Void)? = nil, confirmBlock: (@MainActor @Sendable (String) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
输入框标题
message
输入框消息
cancel
取消按钮文字,默认取消
confirm
确认按钮文字,默认确定
promptBlock
输入框初始化事件,参数为输入框
confirmBlock
确认按钮事件,参数为输入值
cancelBlock
取消按钮事件
-
显示输入框(详细版)
Declaration
Swift
@MainActor public func showPrompt( title: AttributedStringParameter?, message: AttributedStringParameter?, cancel: AttributedStringParameter?, confirm: AttributedStringParameter?, promptCount: Int, promptBlock: (@MainActor @Sendable (UITextField, Int) -> Void)?, confirmBlock: (@MainActor @Sendable ([String]) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
输入框标题
message
输入框消息
cancel
取消按钮文字,默认取消
confirm
确认按钮文字,默认确定
promptCount
输入框数量
promptBlock
输入框初始化事件,参数为输入框和索引index
confirmBlock
确认按钮事件,参数为输入值数组
cancelBlock
取消按钮事件
-
showAlert(title:
message: style: cancel: actions: promptCount: promptBlock: actionBlock: cancelBlock: customBlock: ) 显示弹出框(完整版)
Declaration
Swift
@MainActor public func showAlert( title: AttributedStringParameter?, message: AttributedStringParameter?, style: AlertStyle = .default, cancel: AttributedStringParameter?, actions: [AttributedStringParameter]?, promptCount: Int = 0, promptBlock: (@MainActor @Sendable (UITextField, Int) -> Void)? = nil, actionBlock: (@MainActor @Sendable ([String], Int) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)?, customBlock: (@MainActor @Sendable (Any) -> Void)? )
Parameters
title
弹出框标题
message
弹出框消息
style
弹出框样式
cancel
取消按钮标题,默认Alert单按钮关闭,Alert多按钮或Sheet取消
actions
动作按钮标题列表
promptCount
输入框数量,默认0
promptBlock
输入框初始化事件,参数为输入框和索引index,默认nil
actionBlock
动作按钮点击事件,参数为输入值数组和索引index
cancelBlock
取消按钮事件
customBlock
自定义弹出框事件
-
显示操作表(无动作)
Declaration
Swift
@MainActor public func showSheet( title: AttributedStringParameter?, message: AttributedStringParameter?, cancel: AttributedStringParameter?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
操作表标题
message
操作表消息
cancel
取消按钮标题,默认取消
cancelBlock
取消按钮事件
-
显示操作表(简单版)
Declaration
Swift
@MainActor public func showSheet( title: AttributedStringParameter?, message: AttributedStringParameter?, actions: [AttributedStringParameter]?, actionBlock: (@MainActor @Sendable (Int) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
操作表标题
message
操作表消息
actions
动作按钮标题列表
actionBlock
动作按钮点击事件,参数为索引index
cancelBlock
取消按钮事件
-
显示操作表(详细版)
Declaration
Swift
@MainActor public func showSheet( title: AttributedStringParameter?, message: AttributedStringParameter?, cancel: AttributedStringParameter?, actions: [AttributedStringParameter]?, currentIndex: Int = -1, actionBlock: (@MainActor @Sendable (Int) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)? = nil )
Parameters
title
操作表标题
message
操作表消息
cancel
取消按钮标题,默认取消
actions
动作按钮标题列表
currentIndex
当前选中动作索引,默认-1
actionBlock
动作按钮点击事件,参数为索引index
cancelBlock
取消按钮事件
-
显示弹出框(完整版)
Declaration
Swift
@MainActor public func showSheet( title: AttributedStringParameter?, message: AttributedStringParameter?, cancel: AttributedStringParameter?, actions: [AttributedStringParameter]?, currentIndex: Int = -1, actionBlock: (@MainActor @Sendable (Int) -> Void)?, cancelBlock: (@MainActor @Sendable () -> Void)?, customBlock: (@MainActor @Sendable (Any) -> Void)? )
Parameters
title
操作表标题
message
操作表消息
cancel
取消按钮标题,默认Alert单按钮关闭,Alert多按钮或Sheet取消
actions
动作按钮标题列表
currentIndex
当前选中动作索引,默认-1
actionBlock
动作按钮点击事件,参数为输入值数组和索引index
cancelBlock
取消按钮事件
customBlock
自定义弹出框事件
-
手工隐藏弹出框,完成后回调
Declaration
Swift
@MainActor public func hideAlert( animated: Bool, completion: (@MainActor @Sendable () -> Void)? = nil )
Parameters
animated
是否执行动画
completion
完成回调
-
判断是否正在显示弹出框
Declaration
Swift
@MainActor public var isShowingAlert: Bool { get }
-
自定义样式,默认为样式单例
Declaration
Swift
@MainActor public var alertAppearance: AlertAppearance! { get set }
-
是否是推荐动作
Declaration
Swift
@MainActor public var isPreferred: Bool { get set }
-
指定标题颜色
Declaration
Swift
@MainActor public var titleColor: UIColor? { get set }
-
快速创建弹出动作,title仅支持NSString
Declaration
Swift
@MainActor public static func action( object: AttributedStringParameter?, style: UIAlertAction.Style, handler: (@MainActor @Sendable (UIAlertAction) -> Void)? ) -> UIAlertAction
-
快速创建弹出动作,title仅支持NSString,支持appearance
Declaration
Swift
@MainActor public static func action( object: AttributedStringParameter?, style: UIAlertAction.Style, appearance: AlertAppearance?, handler: (@MainActor @Sendable (UIAlertAction) -> Void)? ) -> UIAlertAction
-
自定义样式,默认为样式单例
Declaration
Swift
@MainActor public var alertAppearance: AlertAppearance! { get set }
-
弹出框样式,默认为Default
Declaration
Swift
@MainActor public var alertStyle: AlertStyle { get set }
-
设置属性标题
Declaration
Swift
@MainActor public var attributedTitle: NSAttributedString? { get set }
-
设置属性消息
Declaration
Swift
@MainActor public var attributedMessage: NSAttributedString? { get set }
-
快速创建弹出控制器,title和message仅支持NSString
Declaration
Swift
@MainActor public static func alertController( title: AttributedStringParameter?, message: AttributedStringParameter?, preferredStyle: UIAlertController.Style ) -> UIAlertController
-
快速创建弹出控制器,title和message仅支持NSString,支持自定义样式
Declaration
Swift
@MainActor public static func alertController( title titleObject: AttributedStringParameter?, message messageObject: AttributedStringParameter?, preferredStyle: UIAlertController.Style, appearance: AlertAppearance? ) -> UIAlertController
-
自定义空界面插件,未设置时自动从插件池加载
Declaration
Swift
@MainActor public var emptyPlugin: EmptyPlugin! { get set }
-
设置空界面外间距,默认zero
Declaration
Swift
@MainActor public var emptyInsets: UIEdgeInsets { get set }
-
获取正在显示的空界面视图
Declaration
Swift
@MainActor public var showingEmptyView: UIView? { get }
-
是否显示空界面
Declaration
Swift
@MainActor public var hasEmptyView: Bool { get }
-
显示空界面加载视图
Declaration
Swift
@MainActor public func showEmptyLoading()
-
显示错误空界面
Declaration
Swift
@MainActor public func showEmptyView( error: Error?, action: AttributedStringParameter? = nil, block: (@MainActor @Sendable (Any) -> Void)? = nil )
-
显示空界面,指定文本、详细文本、图片和动作按钮
Declaration
Swift
@MainActor public func showEmptyView( text: AttributedStringParameter? = nil, detail: AttributedStringParameter? = nil, image: UIImage? = nil, action: AttributedStringParameter? = nil, block: (@MainActor @Sendable (Any) -> Void)? = nil )
-
显示空界面,指定文本、详细文本、图片、是否显示加载视图和动作按钮
Declaration
Swift
@MainActor public func showEmptyView( text: AttributedStringParameter?, detail: AttributedStringParameter?, image: UIImage?, loading: Bool, action: AttributedStringParameter?, block: (@MainActor @Sendable (Any) -> Void)?, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
-
显示空界面,指定文本、详细文本、图片、是否显示加载视图和最多两个动作按钮
Declaration
Swift
@MainActor public func showEmptyView( text: AttributedStringParameter?, detail: AttributedStringParameter?, image: UIImage?, loading: Bool, actions: [AttributedStringParameter]?, block: (@MainActor @Sendable (Int, Any) -> Void)?, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
-
隐藏空界面
Declaration
Swift
@MainActor public func hideEmptyView()
-
自定义空界面插件,未设置时自动从插件池加载
Declaration
Swift
@MainActor public var emptyPlugin: EmptyPlugin! { get set }
-
设置空界面外间距,默认zero
Declaration
Swift
@MainActor public var emptyInsets: UIEdgeInsets { get set }
-
获取正在显示的空界面视图
Declaration
Swift
@MainActor public var showingEmptyView: UIView? { get }
-
是否显示空界面
Declaration
Swift
@MainActor public var hasEmptyView: Bool { get }
-
显示空界面加载视图
Declaration
Swift
@MainActor public func showEmptyLoading()
-
显示错误空界面
Declaration
Swift
@MainActor public func showEmptyView( error: Error?, action: AttributedStringParameter? = nil, block: (@MainActor @Sendable (Any) -> Void)? = nil )
-
显示空界面,指定文本、详细文本、图片和动作按钮
Declaration
Swift
@MainActor public func showEmptyView( text: AttributedStringParameter? = nil, detail: AttributedStringParameter? = nil, image: UIImage? = nil, action: AttributedStringParameter? = nil, block: (@MainActor @Sendable (Any) -> Void)? = nil )
-
显示空界面,指定文本、详细文本、图片、是否显示加载视图和动作按钮
Declaration
Swift
@MainActor public func showEmptyView( text: AttributedStringParameter?, detail: AttributedStringParameter?, image: UIImage?, loading: Bool, action: AttributedStringParameter?, block: (@MainActor @Sendable (Any) -> Void)?, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
-
显示空界面,指定文本、详细文本、图片、是否显示加载视图和最多两个动作按钮
Declaration
Swift
@MainActor public func showEmptyView( text: AttributedStringParameter?, detail: AttributedStringParameter?, image: UIImage?, loading: Bool, actions: [AttributedStringParameter]?, block: (@MainActor @Sendable (Int, Any) -> Void)?, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
-
隐藏空界面
Declaration
Swift
@MainActor public func hideEmptyView()
-
空界面代理,默认nil。DZNEmptyDataSet
Declaration
Swift
@MainActor public weak var emptyViewDelegate: EmptyViewDelegate? { get set }
-
刷新空界面
Declaration
Swift
@MainActor public func reloadEmptyView()
-
当前数据总条数,默认自动调用tableView和collectionView的dataSource,支持自定义覆盖(优先级高,小于0还原)
注意:此处为当前数据源总数,并非当前cell总数,即使tableView未reloadData也会返回新总数
Declaration
Swift
@MainActor public var totalDataCount: Int { get set }
-
滚动视图自定义浮层,用于显示空界面等,兼容UITableView|UICollectionView
Declaration
Swift
@MainActor public var overlayView: UIView { get }
-
是否显示自定义浮层
Declaration
Swift
@MainActor public var hasOverlayView: Bool { get }
-
显示自定义浮层,默认不执行渐变动画,自动添加到滚动视图顶部、表格视图底部
Declaration
Swift
@MainActor public func showOverlayView(animated: Bool = false)
-
隐藏自定义浮层,自动从滚动视图移除
Declaration
Swift
@MainActor public func hideOverlayView()
-
根据名称从指定bundle加载UIImage,优先加载图片文件(无缓存),文件不存在时尝试系统imageNamed方式(有缓存)。支持设置图片解码选项
Declaration
Swift
public static func imageNamed( _ name: String, bundle: Bundle? = nil, options: [ImageCoderOptions: Any]? = nil ) -> UIImage?
-
从图片文件路径解码创建UIImage,自动识别scale,支持动图
Declaration
Swift
public static func image(contentsOfFile path: String) -> UIImage?
-
从图片数据解码创建UIImage,默认scale为1,支持动图。支持设置图片解码选项
Declaration
Swift
public static func image( data: Data?, scale: CGFloat = 1, options: [ImageCoderOptions: Any]? = nil ) -> UIImage?
-
从UIImage编码创建图片数据,支持动图。支持设置图片编码选项
Declaration
Swift
public static func data( image: UIImage?, options: [ImageCoderOptions: Any]? = nil ) -> Data?
-
下载网络图片并返回下载凭据,指定option
Declaration
Swift
@discardableResult public static func downloadImage( _ url: URLParameter?, options: WebImageOptions = [], context: [ImageCoderOptions: Any]? = nil, completion: @escaping @MainActor @Sendable (UIImage?, Data?, Error?) -> Void, progress: (@MainActor @Sendable (Double) -> Void)? = nil ) -> Any?
-
指定下载凭据取消网络图片下载
Declaration
Swift
public static func cancelImageDownload(_ receipt: Any?)
-
自定义图片插件,未设置时自动从插件池加载
Declaration
Swift
@MainActor public var imagePlugin: ImagePlugin? { get set }
-
当前正在加载的网络图片URL
Declaration
Swift
@MainActor public var imageURL: URL? { get }
-
加载网络图片内部方法,支持占位、选项、图片句柄、回调和进度,优先加载插件,默认使用框架网络库
Declaration
Swift
@MainActor public func setImage( url: URLParameter?, placeholderImage: UIImage?, options: WebImageOptions, context: [ImageCoderOptions: Any]?, setImageBlock: (@MainActor @Sendable (UIImage?) -> Void)?, completion: (@MainActor @Sendable (UIImage?, Error?) -> Void)?, progress: (@MainActor @Sendable (Double) -> Void)? )
-
取消加载网络图片请求
Declaration
Swift
@MainActor public func cancelImageRequest()
-
加载指定URL的本地缓存图片
Declaration
Swift
@MainActor public func loadImageCache(url: URLParameter?) -> UIImage?
-
是否隐藏全局图片加载指示器,默认false,仅全局图片指示器开启时生效
Declaration
Swift
@MainActor public var hidesImageIndicator: Bool { get set }
-
加载网络图片,支持占位、选项、回调和进度,优先加载插件,默认使用框架网络库
Declaration
Swift
@MainActor public func setImage( url: URLParameter?, placeholderImage: UIImage? = nil, options: WebImageOptions = [], context: [ImageCoderOptions: Any]? = nil, completion: (@MainActor @Sendable (UIImage?, Error?) -> Void)? = nil, progress: (@MainActor @Sendable (Double) -> Void)? = nil )
-
加载指定URL的本地缓存图片
Declaration
Swift
public nonisolated static func loadImageCache(url: URLParameter?) -> UIImage?
-
清除所有本地图片缓存
Declaration
Swift
public nonisolated static func clearImageCaches(completion: (@MainActor @Sendable () -> Void)? = nil)
-
创建动画ImageView视图,优先加载插件,默认UIImageView
Declaration
Swift
@MainActor public static func animatedImageView() -> UIImageView
-
加载网络图片,支持占位、选项、回调和进度,优先加载插件,默认使用框架网络库
Declaration
Swift
@MainActor public func setImage( url: URLParameter?, placeholderImage: UIImage? = nil, options: WebImageOptions = [], context: [ImageCoderOptions: Any]? = nil, completion: (@MainActor @Sendable (UIImage?, Error?) -> Void)? = nil, progress: (@MainActor @Sendable (Double) -> Void)? = nil )
-
downloadImage(_:
Asynchronousoptions: context: ) 异步下载网络图片
Declaration
Swift
public static func downloadImage( _ url: URLParameter?, options: WebImageOptions = [], context: [ImageCoderOptions: Any]? = nil ) async throws -> UIImage
-
快速创建照片选择器(仅图片)
@param selectionLimit 最大选择数量,iOS14以下只支持单选 @param allowsEditing 是否允许编辑,仅iOS14以下支持编辑 @param completion 完成回调,主线程。参数1为图片数组,2为结果数组,3为是否取消 @return 照片选择器
Declaration
Swift
@MainActor public static func pickerController( selectionLimit: Int, allowsEditing: Bool, completion: @escaping @MainActor @Sendable ([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
@MainActor public static func pickerController( filterType: ImagePickerFilterType, selectionLimit: Int, allowsEditing: Bool, shouldDismiss: Bool, completion: @escaping @MainActor @Sendable (UIViewController?, [Any], [Any], Bool) -> Void ) -> UIViewController?
-
快速创建照片选择器(仅图片),使用自定义裁剪控制器编辑
@param selectionLimit 最大选择数量 @param cropController 自定义裁剪控制器句柄,nil时自动创建默认裁剪控制器 @param completion 完成回调,主线程。参数1为图片数组,2为结果数组,3为是否取消 @return 照片选择器
Declaration
Swift
@MainActor public static func pickerController( selectionLimit: Int, cropController: (@MainActor @Sendable (UIImage) -> ImageCropController)?, completion: @escaping @MainActor @Sendable ([UIImage], [Any], Bool) -> Void ) -> UIViewController?
-
自定义图片选取插件,未设置时自动从插件池加载
Declaration
Swift
@MainActor public var imagePickerPlugin: ImagePickerPlugin! { get set }
-
从Camera选取单张图片(简单版)
Declaration
Swift
@MainActor public func showImageCamera( allowsEditing: Bool, completion: @escaping @MainActor @Sendable (UIImage?, Bool) -> Void )
Parameters
allowsEditing
是否允许编辑
completion
完成回调,主线程。参数1为图片,2为是否取消
-
从Camera选取单张图片(详细版)
Declaration
Swift
@MainActor public func showImageCamera( filterType: ImagePickerFilterType, allowsEditing: Bool, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil, completion: @escaping @MainActor @Sendable (Any?, Any?, Bool) -> Void )
Parameters
filterType
过滤类型,默认0同系统
allowsEditing
是否允许编辑
customBlock
自定义配置句柄,默认nil