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 }
-
快速创建flowLayout
Declaration
Swift
@MainActor public static func flowLayout() -> UICollectionViewFlowLayout
-
快速创建collectionView,可自定义collectionViewLayout(默认flowLayout),可启用collectionDelegate(默认false)
Declaration
Swift
@MainActor public static func collectionView(_ viewLayout: UICollectionViewLayout? = nil, delegateEnabled: Bool = false) -> 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,可配置钩子句柄,可启用tableDelegate(默认false)
Declaration
Swift
@MainActor public static func tableView(_ style: UITableView.Style = .plain, delegateEnabled: Bool = false) -> 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
completion
完成回调,主线程。参数1为对象(UIImage|PHLivePhoto|NSURL),2为结果信息,3为是否取消
-
从图片库选取单张图片(简单版)
Declaration
Swift
@MainActor public func showImagePicker( allowsEditing: Bool, completion: @escaping @MainActor @Sendable (UIImage?, Bool) -> Void )
Parameters
allowsEditing
是否允许编辑
completion
完成回调,主线程。参数1为图片,2为是否取消
-
从图片库选取多张图片(简单版)
Declaration
Swift
@MainActor public func showImagePicker( selectionLimit: Int, allowsEditing: Bool, completion: @escaping @MainActor @Sendable ([UIImage], [Any], Bool) -> Void )
Parameters
selectionLimit
最大选择数量
allowsEditing
是否允许编辑
completion
完成回调,主线程。参数1为图片数组,2为结果数组,3为是否取消
-
从图片库选取多张图片(详细版)
Declaration
Swift
@MainActor public func showImagePicker( filterType: ImagePickerFilterType, selectionLimit: Int, allowsEditing: Bool, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil, completion: @escaping @MainActor @Sendable ([Any], [Any], Bool) -> Void )
Parameters
filterType
过滤类型,默认0同系统
selectionLimit
最大选择数量
allowsEditing
是否允许编辑
customBlock
自定义配置句柄,默认nil
completion
完成回调,主线程。参数1为对象数组(UIImage|PHLivePhoto|NSURL),2位结果数组,3为是否取消
-
从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
completion
完成回调,主线程。参数1为对象(UIImage|PHLivePhoto|NSURL),2为结果信息,3为是否取消
-
从图片库选取单张图片(简单版)
Declaration
Swift
@MainActor public func showImagePicker( allowsEditing: Bool, completion: @escaping @MainActor @Sendable (UIImage?, Bool) -> Void )
Parameters
allowsEditing
是否允许编辑
completion
完成回调,主线程。参数1为图片,2为是否取消
-
从图片库选取多张图片(简单版)
Declaration
Swift
@MainActor public func showImagePicker( selectionLimit: Int, allowsEditing: Bool, completion: @escaping @MainActor @Sendable ([UIImage], [Any], Bool) -> Void )
Parameters
selectionLimit
最大选择数量
allowsEditing
是否允许编辑
completion
完成回调,主线程。参数1为图片数组,2为结果数组,3为是否取消
-
从图片库选取多张图片(详细版)
Declaration
Swift
@MainActor public func showImagePicker( filterType: ImagePickerFilterType, selectionLimit: Int, allowsEditing: Bool, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil, completion: @escaping @MainActor @Sendable ([Any], [Any], Bool) -> Void )
Parameters
filterType
过滤类型,默认0同系统
selectionLimit
最大选择数量
allowsEditing
是否允许编辑
customBlock
自定义配置句柄,默认nil
completion
完成回调,主线程。参数1为对象数组(UIImage|PHLivePhoto|NSURL),2位结果数组,3为是否取消
-
快速创建单选照片选择器(仅图片),自动设置delegate
@param sourceType 选择器类型 @param allowsEditing 是否允许编辑 @param completion 完成回调。参数1为图片,2为信息字典,3为是否取消 @return 照片选择器,不支持的返回nil
Declaration
Swift
@MainActor public static func pickerController( sourceType: UIImagePickerController.SourceType, allowsEditing: Bool, completion: @escaping @MainActor @Sendable (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
@MainActor public static func pickerController( sourceType: UIImagePickerController.SourceType, filterType: ImagePickerFilterType, allowsEditing: Bool, shouldDismiss: Bool, completion: @escaping @MainActor @Sendable (UIImagePickerController?, Any?, [AnyHashable: Any]?, Bool) -> Void ) -> UIImagePickerController?
-
快速创建单选照片选择器,使用自定义裁剪控制器编辑
@param sourceType 选择器类型 @param cropController 自定义裁剪控制器句柄,nil时自动创建默认裁剪控制器 @param completion 完成回调。参数1为图片,2为信息字典,3为是否取消 @return 照片选择器,不支持的返回nil
Declaration
Swift
@MainActor public static func pickerController( sourceType: UIImagePickerController.SourceType, cropController cropControllerBlock: (@MainActor @Sendable (UIImage) -> ImageCropController)?, completion: @escaping @MainActor @Sendable (UIImage?, [AnyHashable: Any]?, Bool) -> Void ) -> UIImagePickerController?
-
快速创建多选照片选择器(仅图片),自动设置delegate
@param selectionLimit 最大选择数量 @param completion 完成回调,主线程。参数1为图片数组,2为结果数组,3为是否取消 @return 照片选择器
Declaration
Swift
@MainActor public static func pickerController( selectionLimit: Int, completion: @escaping @MainActor @Sendable ([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
@MainActor public static func pickerController( filterType: ImagePickerFilterType, selectionLimit: Int, shouldDismiss: Bool, completion: @escaping @MainActor @Sendable (PHPickerViewController?, [Any], [PHPickerResult], Bool) -> Void ) -> PHPickerViewController
-
快速创建照片选择器(仅图片),使用自定义裁剪控制器编辑
@param selectionLimit 最大选择数量 @param cropController 自定义裁剪控制器句柄,nil时自动创建默认裁剪控制器 @param completion 完成回调,主线程。参数1为图片数组,2为结果数组,3为是否取消 @return 照片选择器
Declaration
Swift
@MainActor public static func pickerController( selectionLimit: Int, cropController cropControllerBlock: (@MainActor @Sendable (UIImage) -> ImageCropController)?, completion: @escaping @MainActor @Sendable ([UIImage], [PHPickerResult], Bool) -> Void ) -> PHPickerViewController
-
自定义全局PHPickerConfiguration创建句柄,默认nil
Declaration
Swift
@MainActor public static var pickerConfigurationBlock: (() -> PHPickerConfiguration)? { get set }
-
照片选择器是否已经dismiss,用于解决didFinishPicking回调多次问题
Declaration
Swift
@MainActor public var pickerControllerDismissed: Bool { get set }
-
自定义照片选择器导出进度句柄,主线程回调,默认nil
Declaration
Swift
@MainActor public var exportProgressBlock: ((_ picker: PHPickerViewController, _ finishedCount: Int, _ totalCount: Int) -> Void)? { get set }
-
自定义图片预览插件,未设置时自动从插件池加载
Declaration
Swift
@MainActor public var imagePreviewPlugin: ImagePreviewPlugin! { get set }
-
显示图片预览(简单版)
Declaration
Swift
@MainActor public func showImagePreview( imageURLs: [Any], imageInfos: [Any]? = nil, currentIndex: Int = 0, sourceView: (@MainActor @Sendable (Int) -> Any?)? = nil )
Parameters
imageURLs
预览图片列表,支持NSString|UIImage|PHLivePhoto|AVPlayerItem类型
imageInfos
自定义图片信息数组
currentIndex
当前索引,默认0
sourceView
来源视图,可选,支持UIView|NSValue.CGRect,默认nil
-
showImagePreview(imageURLs:
imageInfos: currentIndex: sourceView: placeholderImage: renderBlock: customBlock: ) 显示图片预览(详细版)
Declaration
Swift
@MainActor public func showImagePreview( imageURLs: [Any], imageInfos: [Any]?, currentIndex: Int, sourceView: (@MainActor @Sendable (Int) -> Any?)?, placeholderImage: (@MainActor @Sendable (Int) -> UIImage?)?, renderBlock: (@MainActor @Sendable (UIView, Int) -> Void)? = nil, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
Parameters
imageURLs
预览图片列表,支持NSString|UIImage|PHLivePhoto|AVPlayerItem类型
imageInfos
自定义图片信息数组
currentIndex
当前索引,默认0
sourceView
来源视图句柄,支持UIView|NSValue.CGRect,默认nil
placeholderImage
占位图或缩略图句柄,默认nil
renderBlock
自定义渲染句柄,默认nil
customBlock
自定义句柄,默认nil
-
显示图片预览(简单版)
Declaration
Swift
@MainActor public func showImagePreview( imageURLs: [Any], imageInfos: [Any]? = nil, currentIndex: Int = 0, sourceView: (@MainActor @Sendable (Int) -> Any?)? = nil )
Parameters
imageURLs
预览图片列表,支持NSString|UIImage|PHLivePhoto|AVPlayerItem类型
imageInfos
自定义图片信息数组
currentIndex
当前索引,默认0
sourceView
来源视图,可选,支持UIView|NSValue.CGRect,默认nil
-
showImagePreview(imageURLs:
imageInfos: currentIndex: sourceView: placeholderImage: renderBlock: customBlock: ) 显示图片预览(详细版)
Declaration
Swift
@MainActor public func showImagePreview( imageURLs: [Any], imageInfos: [Any]?, currentIndex: Int, sourceView: (@MainActor @Sendable (Int) -> Any?)?, placeholderImage: (@MainActor @Sendable (Int) -> UIImage?)?, renderBlock: (@MainActor @Sendable (UIView, Int) -> Void)? = nil, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
Parameters
imageURLs
预览图片列表,支持NSString|UIImage|PHLivePhoto|AVPlayerItem类型
imageInfos
自定义图片信息数组
currentIndex
当前索引,默认0
sourceView
来源视图句柄,支持UIView|NSValue.CGRect,默认nil
placeholderImage
占位图或缩略图句柄,默认nil
renderBlock
自定义渲染句柄,默认nil
customBlock
自定义句柄,默认nil
-
自定义刷新插件,未设置时自动从插件池加载
Declaration
Swift
@MainActor public var refreshPlugin: RefreshPlugin! { get set }
-
是否正在刷新中
Declaration
Swift
@MainActor public var isRefreshing: Bool { get }
-
是否显示刷新组件
Declaration
Swift
@MainActor public var shouldRefreshing: Bool { get set }
-
配置下拉刷新句柄
Declaration
Swift
@MainActor public func setRefreshing(block: @escaping @MainActor @Sendable () -> Void, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil)
-
配置下拉刷新事件
Declaration
Swift
@MainActor public func setRefreshing(target: Any, action: Selector, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil)
-
开始下拉刷新
Declaration
Swift
@MainActor public func beginRefreshing()
-
结束下拉刷新
Declaration
Swift
@MainActor public func endRefreshing()
-
结束下拉刷新并标记是否加载完成,需在reloadData之后调用
Declaration
Swift
@MainActor public func endRefreshing(finished: Bool)
-
是否正在追加中
Declaration
Swift
@MainActor public var isLoading: Bool { get }
-
是否显示追加组件
Declaration
Swift
@MainActor public var shouldLoading: Bool { get set }
-
是否已加载完成,不能继续追加,需在reloadData之后调用
Declaration
Swift
@MainActor public var loadingFinished: Bool { get set }
-
配置上拉追加句柄
Declaration
Swift
@MainActor public func setLoading(block: @escaping @MainActor @Sendable () -> Void, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil)
-
配置上拉追加事件
Declaration
Swift
@MainActor public func setLoading(target: Any, action: Selector, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil)
-
开始上拉追加
Declaration
Swift
@MainActor public func beginLoading()
-
结束上拉追加
Declaration
Swift
@MainActor public func endLoading()
-
结束上拉追加并标记是否加载完成,需在reloadData之后调用
Declaration
Swift
@MainActor public func endLoading(finished: Bool)
-
Undocumented
Declaration
Swift
@MainActor public func addPullRefresh(block: @escaping @MainActor @Sendable () -> Void)
-
Undocumented
Declaration
Swift
@MainActor public func addPullRefresh(target: Any, action: Selector)
-
Undocumented
Declaration
Swift
@MainActor public func triggerPullRefresh()
-
Undocumented
Declaration
Swift
@MainActor public var pullRefreshView: PullRefreshView? { get set }
-
Undocumented
Declaration
Swift
@MainActor public var showPullRefresh: Bool { get set }
-
Undocumented
Declaration
Swift
@MainActor public func addInfiniteScroll(block: @escaping @MainActor @Sendable () -> Void)
-
Undocumented
Declaration
Swift
@MainActor public func addInfiniteScroll(target: Any, action: Selector)
-
Undocumented
Declaration
Swift
@MainActor public func triggerInfiniteScroll()
-
Undocumented
Declaration
Swift
@MainActor public var infiniteScrollView: InfiniteScrollView? { get set }
-
Undocumented
Declaration
Swift
@MainActor public var showInfiniteScroll: Bool { get set }
-
Undocumented
Declaration
Swift
@MainActor public var infiniteScrollFinished: Bool { get set }
-
自定义吐司插件,未设置时自动从插件池加载
Declaration
Swift
@MainActor public var toastPlugin: ToastPlugin! { get set }
-
设置吐司外间距,默认zero
Declaration
Swift
@MainActor public var toastInsets: UIEdgeInsets { get set }
-
显示加载吐司,默认需手工隐藏,指定cancelBlock时点击会自动隐藏并调用之,支持String和AttributedString
Declaration
Swift
@MainActor public func showLoading( text: AttributedStringParameter? = nil, detail: AttributedStringParameter? = nil, cancelBlock: (@MainActor @Sendable () -> Void)? = nil, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
-
隐藏加载吐司,可指定延迟隐藏从而实现连续的加载效果
Declaration
Swift
@MainActor public func hideLoading(delayed: Bool = false)
-
获取正在显示的加载吐司视图
Declaration
Swift
@MainActor public var showingLoadingView: UIView? { get }
-
是否正在显示加载吐司
Declaration
Swift
@MainActor public var isShowingLoading: Bool { get }
-
显示进度条吐司,默认需手工隐藏,指定cancelBlock时点击会自动隐藏并调用之,支持String和AttributedString
Declaration
Swift
@MainActor public func showProgress( _ progress: CGFloat, text: AttributedStringParameter? = nil, detail: AttributedStringParameter? = nil, cancelBlock: (@MainActor @Sendable () -> Void)? = nil, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
-
隐藏进度条吐司
Declaration
Swift
@MainActor public func hideProgress()
-
获取正在显示的进度条吐司视图
Declaration
Swift
@MainActor public var showingProgressView: UIView? { get }
-
是否正在显示进度条吐司
Declaration
Swift
@MainActor public var isShowingProgress: Bool { get }
-
显示错误消息吐司,自动隐藏,自动隐藏完成后回调
Declaration
Swift
@MainActor public func showMessage( error: Error?, completion: (@MainActor @Sendable () -> Void)? = nil )
-
显示指定样式消息吐司,默认自动隐藏,自动隐藏完成后回调,支持String和AttributedString
Declaration
Swift
@MainActor public func showMessage( text: AttributedStringParameter?, detail: AttributedStringParameter? = nil, style: ToastStyle = .default, autoHide: Bool = true, interactive: Bool? = nil, completion: (@MainActor @Sendable () -> Void)? = nil, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
-
隐藏消息吐司
Declaration
Swift
@MainActor public func hideMessage()
-
获取正在显示的消息吐司视图
Declaration
Swift
@MainActor public var showingMessageView: UIView? { get }
-
是否正在显示消息吐司
Declaration
Swift
@MainActor public var isShowingMessage: Bool { get }
-
设置吐司是否显示在window上,默认NO,显示到view上
Declaration
Swift
@MainActor public var toastInWindow: Bool { get set }
-
设置吐司是否显示在祖先视图上,默认NO,显示到view上
Declaration
Swift
@MainActor public var toastInAncestor: Bool { get set }
-
自定义吐司插件,未设置时自动从插件池加载
Declaration
Swift
@MainActor public var toastPlugin: ToastPlugin! { get set }
-
设置吐司外间距,默认zero
Declaration
Swift
@MainActor public var toastInsets: UIEdgeInsets { get set }
-
获取或设置吐司容器视图,默认view
Declaration
Swift
@MainActor public var toastContainer: UIView! { get set }
-
显示加载吐司,默认需手工隐藏,指定cancelBlock时点击会自动隐藏并调用之,支持String和AttributedString
Declaration
Swift
@MainActor public func showLoading( text: AttributedStringParameter? = nil, detail: AttributedStringParameter? = nil, cancelBlock: (@MainActor @Sendable () -> Void)? = nil, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
-
隐藏加载吐司,可指定延迟隐藏从而实现连续的加载效果
Declaration
Swift
@MainActor public func hideLoading(delayed: Bool = false)
-
获取正在显示的加载吐司视图
Declaration
Swift
@MainActor public var showingLoadingView: UIView? { get }
-
是否正在显示加载吐司
Declaration
Swift
@MainActor public var isShowingLoading: Bool { get }
-
显示进度条吐司,默认需手工隐藏,指定cancelBlock时点击会自动隐藏并调用之,支持String和AttributedString
Declaration
Swift
@MainActor public func showProgress( _ progress: CGFloat, text: AttributedStringParameter? = nil, detail: AttributedStringParameter? = nil, cancelBlock: (@MainActor @Sendable () -> Void)? = nil, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
-
隐藏进度条吐司
Declaration
Swift
@MainActor public func hideProgress()
-
获取正在显示的进度条吐司视图
Declaration
Swift
@MainActor public var showingProgressView: UIView? { get }
-
是否正在显示进度条吐司
Declaration
Swift
@MainActor public var isShowingProgress: Bool { get }
-
显示错误消息吐司,自动隐藏,自动隐藏完成后回调
Declaration
Swift
@MainActor public func showMessage( error: Error?, completion: (@MainActor @Sendable () -> Void)? = nil )
-
显示指定样式消息吐司,默认自动隐藏,自动隐藏完成后回调,支持String和AttributedString
Declaration
Swift
@MainActor public func showMessage( text: AttributedStringParameter?, detail: AttributedStringParameter? = nil, style: ToastStyle = .default, autoHide: Bool = true, interactive: Bool? = nil, completion: (@MainActor @Sendable () -> Void)? = nil, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
-
隐藏消息吐司
Declaration
Swift
@MainActor public func hideMessage()
-
获取正在显示的消息吐司视图
Declaration
Swift
@MainActor public var showingMessageView: UIView? { get }
-
是否正在显示消息吐司
Declaration
Swift
@MainActor public var isShowingMessage: Bool { get }
-
自定义吐司插件,未设置时自动从插件池加载
Declaration
Swift
@MainActor public static var toastPlugin: ToastPlugin! { get set }
-
设置吐司外间距,默认zero
Declaration
Swift
@MainActor public static var toastInsets: UIEdgeInsets { get set }
-
显示加载吐司,默认需手工隐藏,指定cancelBlock时点击会自动隐藏并调用之,支持String和AttributedString
Declaration
Swift
@MainActor public static func showLoading( text: AttributedStringParameter? = nil, detail: AttributedStringParameter? = nil, cancelBlock: (@MainActor @Sendable () -> Void)? = nil, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
-
隐藏加载吐司,可指定延迟隐藏从而实现连续的加载效果
Declaration
Swift
@MainActor public static func hideLoading(delayed: Bool = false)
-
获取正在显示的加载吐司视图
Declaration
Swift
@MainActor public static var showingLoadingView: UIView? { get }
-
是否正在显示加载吐司
Declaration
Swift
@MainActor public static var isShowingLoading: Bool { get }
-
显示进度条吐司,默认需手工隐藏,指定cancelBlock时点击会自动隐藏并调用之,支持String和AttributedString
Declaration
Swift
@MainActor public static func showProgress( _ progress: CGFloat, text: AttributedStringParameter? = nil, detail: AttributedStringParameter? = nil, cancelBlock: (@MainActor @Sendable () -> Void)? = nil, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
-
隐藏进度条吐司
Declaration
Swift
@MainActor public static func hideProgress()
-
获取正在显示的进度条吐司视图
Declaration
Swift
@MainActor public static var showingProgressView: UIView? { get }
-
是否正在显示进度条吐司
Declaration
Swift
@MainActor public static var isShowingProgress: Bool { get }
-
显示错误消息吐司,自动隐藏,自动隐藏完成后回调
Declaration
Swift
@MainActor public static func showMessage( error: Error?, completion: (@MainActor @Sendable () -> Void)? = nil )
-
显示指定样式消息吐司,默认自动隐藏,自动隐藏完成后回调,支持String和AttributedString
Declaration
Swift
@MainActor public static func showMessage( text: AttributedStringParameter?, detail: AttributedStringParameter? = nil, style: ToastStyle = .default, autoHide: Bool = true, interactive: Bool? = nil, completion: (@MainActor @Sendable () -> Void)? = nil, customBlock: (@MainActor @Sendable (Any) -> Void)? = nil )
-
隐藏消息吐司
Declaration
Swift
@MainActor public static func hideMessage()
-
获取正在显示的消息吐司视图
Declaration
Swift
@MainActor public static var showingMessageView: UIView? { get }
-
是否正在显示消息吐司
Declaration
Swift
@MainActor public static var isShowingMessage: Bool { get }
-
自定义视图插件,未设置时自动从插件池加载
Declaration
Swift
@MainActor public var viewPlugin: ViewPlugin! { get set }
-
统一进度视图工厂方法
Declaration
Swift
@MainActor public func progressView(style: ProgressViewStyle = .default) -> UIView & ProgressViewPlugin
-
统一指示器视图工厂方法
Declaration
Swift
@MainActor public func indicatorView(style: IndicatorViewStyle = .default) -> UIView & IndicatorViewPlugin
-
统一进度视图工厂方法
Declaration
Swift
@MainActor public static func progressView(style: ProgressViewStyle = .default) -> UIView & ProgressViewPlugin
-
统一指示器视图工厂方法
Declaration
Swift
@MainActor public static func indicatorView(style: IndicatorViewStyle = .default) -> UIView & IndicatorViewPlugin
-
快速创建指示器,可指定颜色,默认白色
Declaration
Swift
@MainActor public static func indicatorView(color: UIColor?) -> UIActivityIndicatorView
-
图片循环次数,静态图片始终是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获取,获取失败返回ImageFormatUndefined
Declaration
Swift
public var imageFormat: ImageFormat { get set }
-
获取图片数据的格式,未知格式返回ImageFormatUndefined
Declaration
Swift
public static func imageFormat(for imageData: Data?) -> ImageFormat
-
图片格式转化为UTType,未知格式返回kUTTypeImage
Declaration
Swift
public static func utType(from imageFormat: ImageFormat) -> CFString
-
UTType转化为图片格式,未知格式返回ImageFormatUndefined
Declaration
Swift
public static func imageFormat(from utType: CFString) -> ImageFormat
-
图片格式转化为mimeType,未知格式返回application/octet-stream
Declaration
Swift
public static func mimeType(from imageFormat: ImageFormat) -> String
-
文件后缀转化为mimeType,未知后缀返回application/octet-stream
Declaration
Swift
public static func mimeType(from fileExtension: String) -> String
-
图片数据编码为base64字符串,可直接用于H5显示等,字符串格式:data:image/png;base64,数据
Declaration
Swift
public static func base64String(for imageData: Data?) -> String?
-
图片base64字符串解码为数据,兼容格式:data:image/png;base64,数据
Declaration
Swift
public static func imageData(for base64String: String?) -> Data?
-
是否是调试模式
Declaration
Swift
public nonisolated static var isDebug: Bool { get }
-
是否是模拟器
Declaration
Swift
public nonisolated static var isSimulator: Bool { get }
-
是否是iPhone
Declaration
Swift
public nonisolated static var isIphone: Bool { get }
-
是否是iPod
Declaration
Swift
public nonisolated static var isIpod: Bool { get }
-
是否是iPad
Declaration
Swift
public nonisolated static var isIpad: Bool { get }
-
是否是Mac
Declaration
Swift
public nonisolated static var isMac: Bool { get }
-
iOS系统版本字符串
Declaration
Swift
public nonisolated static var iosVersionString: String { get }
-
iOS系统版本浮点数
Declaration
Swift
public nonisolated static var iosVersion: Double { get }
-
是否是指定iOS版本
Declaration
Swift
public nonisolated static func isIos(_ major: Int, _ minor: Int? = nil, _ patch: Int? = nil) -> Bool
-
是否是大于等于指定iOS版本
Declaration
Swift
public nonisolated static func isIosLater(_ major: Int, _ minor: Int? = nil, _ patch: Int? = nil) -> Bool
-
设备尺寸,跟横竖屏无关
Declaration
Swift
public nonisolated static var deviceSize: CGSize { get }
-
设备宽度,跟横竖屏无关
Declaration
Swift
public nonisolated static var deviceWidth: CGFloat { get }
-
设备高度,跟横竖屏无关
Declaration
Swift
public nonisolated static var deviceHeight: CGFloat { get }
-
设备分辨率,跟横竖屏无关
Declaration
Swift
public nonisolated static var deviceResolution: CGSize { get }
-
获取设备模型,格式:"iPhone15,1"
Declaration
Swift
public nonisolated static var deviceModel: String { get }
-
设备是否横屏,无论支不支持横屏
Declaration
Swift
public nonisolated static var isDeviceLandscape: Bool { get }
-
设置界面方向,支持旋转方向时生效
Declaration
Swift
@discardableResult @MainActor public static func setDeviceOrientation(_ orientation: UIDeviceOrientation) -> Bool
-
屏幕尺寸
Declaration
Swift
public nonisolated static var screenSize: CGSize { get }
-
屏幕宽度
Declaration
Swift
public nonisolated static var screenWidth: CGFloat { get }
-
屏幕高度
Declaration
Swift
public nonisolated static var screenHeight: CGFloat { get }
-
屏幕像素比例
Declaration
Swift
public nonisolated static var screenScale: CGFloat { get }
-
判断屏幕英寸,需同步适配新机型
Declaration
Swift
public nonisolated static func isScreenInch(_ inch: ScreenInch) -> Bool
-
界面是否横屏
Declaration
Swift
public nonisolated static var isInterfaceLandscape: Bool { get }
-
是否是全面屏屏幕
Declaration
Swift
@MainActor public static var isNotchedScreen: Bool { get }
-
是否是灵动岛屏幕
Declaration
Swift
@MainActor public static var isDynamicIsland: Bool { get }
-
屏幕一像素的大小
Declaration
Swift
public nonisolated static var pixelOne: CGFloat { get }
-
屏幕半个点的大小,区别于pixelOne,2x屏为1像素,3x屏为2像素
Declaration
Swift
public nonisolated static var pointHalf: CGFloat { get }
-
检查是否含有安全区域,可用来判断iPhoneX
Declaration
Swift
@MainActor public static var hasSafeAreaInsets: Bool { get }
-
屏幕安全区域距离
Declaration
Swift
@MainActor public static var safeAreaInsets: UIEdgeInsets { get }
-
状态栏高度,与是否隐藏无关,可自定义
Declaration
Swift
@MainActor public static var statusBarHeight: CGFloat { get }
-
导航栏高度,与是否隐藏无关,可自定义
Declaration
Swift
@MainActor public static var navigationBarHeight: CGFloat { get }
-
顶部栏高度,包含状态栏、导航栏,与是否隐藏无关
Declaration
Swift
@MainActor public static var topBarHeight: CGFloat { get }
-
标签栏高度,与是否隐藏无关,可自定义
Declaration
Swift
@MainActor public static var tabBarHeight: CGFloat { get }
-
工具栏高度,与是否隐藏无关,可自定义
Declaration
Swift
@MainActor public static var toolBarHeight: CGFloat { get }
-
自定义指定界面方向状态栏高度,小于等于0时清空
Declaration
Swift
@MainActor public static func setStatusBarHeight(_ height: CGFloat, for orientation: UIInterfaceOrientation)
-
自定义指定界面方向导航栏高度,小于等于0时清空
Declaration
Swift
@MainActor public static func setNavigationBarHeight(_ height: CGFloat, for orientation: UIInterfaceOrientation)
-
自定义指定界面方向标签栏高度,小于等于0时清空
Declaration
Swift
@MainActor public static func setTabBarHeight(_ height: CGFloat, for orientation: UIInterfaceOrientation)
-
自定义指定界面方向工具栏高度,小于等于0时清空
Declaration
Swift
@MainActor public static func setToolBarHeight(_ height: CGFloat, for orientation: UIInterfaceOrientation)
-
指定等比例缩放参考设计图尺寸,默认{375,812},宽度常用
Declaration
Swift
public nonisolated static var referenceSize: CGSize { get set }
-
全局自定义屏幕宽度缩放比例句柄,默认nil
Declaration
Swift
public nonisolated static var relativeScaleBlock: (@Sendable () -> CGFloat)? { get set }
-
全局自定义屏幕高度缩放比例句柄,默认nil
Declaration
Swift
public nonisolated static var relativeHeightScaleBlock: (@Sendable () -> CGFloat)? { get set }
-
获取当前屏幕宽度缩放比例,宽度常用
Declaration
Swift
public nonisolated static var relativeScale: CGFloat { get }
-
获取当前屏幕高度缩放比例,高度不常用
Declaration
Swift
public nonisolated static var relativeHeightScale: CGFloat { get }
-
获取相对设计图宽度等比例缩放值
Declaration
Swift
public nonisolated static func relativeValue(_ value: CGFloat, flat: Bool = false) -> CGFloat
-
获取相对设计图高度等比例缩放值
Declaration
Swift
public nonisolated static func relativeHeight(_ value: CGFloat, flat: Bool = false) -> CGFloat
-
获取相对设计图宽度等比例缩放时的固定宽度值
Declaration
Swift
public nonisolated static func fixedValue(_ value: CGFloat, flat: Bool = false) -> CGFloat
-
获取相对设计图高度等比例缩放时的固定高度值
Declaration
Swift
public nonisolated static func fixedHeight(_ value: CGFloat, flat: Bool = false) -> CGFloat
-
基于指定的倍数(0取当前设备),对传进来的floatValue进行像素取整
Declaration
Swift
public nonisolated static func flatValue(_ value: CGFloat, scale: CGFloat = 0) -> CGFloat
-
是否自动等比例缩放方式设置transform,默认NO
Declaration
Swift
@MainActor public var autoScaleTransform: Bool { get set }
-
当前状态栏布局高度,导航栏隐藏时为0,推荐使用
Declaration
Swift
@MainActor public var statusBarHeight: CGFloat { get }
-
当前导航栏布局高度,隐藏时为0,推荐使用
Declaration
Swift
@MainActor public var navigationBarHeight: CGFloat { get }
-
当前顶部栏布局高度,导航栏隐藏时为0,推荐使用
Declaration
Swift
@MainActor public var topBarHeight: CGFloat { get }
-
当前标签栏布局高度,隐藏时为0,推荐使用
Declaration
Swift
@MainActor public var tabBarHeight: CGFloat { get }
-
当前工具栏布局高度,隐藏时为0,推荐使用
Declaration
Swift
@MainActor public var toolBarHeight: CGFloat { get }
-
当前底部栏布局高度,包含标签栏和工具栏,隐藏时为0,推荐使用
Declaration
Swift
@MainActor public var bottomBarHeight: CGFloat { get }
-
将对象归档为data数据,兼容NSCoding和AnyArchivable
Declaration
Swift
public static func archivedData(_ object: Any?) -> Data?
-
将数据解档为指定类型对象,需实现NSSecureCoding,推荐使用
Declaration
Swift
public func unarchivedObject<T>(_ clazz: T.Type) -> T? where T : NSObject, T : NSCoding
-
将数据解档为指定AnyArchivable对象,推荐使用
Declaration
Swift
public func unarchivedObject<T>(_ type: T.Type) -> T? where T : AnyArchivable
-
将数据解档为对象,兼容NSCoding和AnyArchivable
Declaration
Swift
public func unarchivedObject() -> Any?
-
将对象归档保存到文件,兼容NSCoding和AnyArchivable
Declaration
Swift
@discardableResult public static func archiveObject(_ object: Any, toFile path: String) -> Bool
-
从文件解档指定类型对象,需实现NSSecureCoding,推荐使用
Declaration
Swift
public static func unarchivedObject<T>(_ clazz: T.Type, withFile path: String) -> T? where T : NSObject, T : NSCoding
-
从文件解档指定AnyArchivable对象,推荐使用
Declaration
Swift
public static func unarchivedObject<T>(_ type: T.Type, withFile path: String) -> T? where T : AnyArchivable
-
从文件解档对象,兼容NSCoding和AnyArchivable
Declaration
Swift
public static func unarchivedObject(withFile path: String) -> Any?
-
是否启用自动布局适配RTL,启用后自动将Left|Right转换为Leading|Trailing,默认NO
如果项目兼容阿拉伯语等,需要启用RTL从右向左布局,开启此开关即可,无需修改布局代码 手工切换视图左右布局方法:[UIView appearance].semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
Declaration
Swift
@MainActor public static var autoLayoutRTL: Bool { get set }
-
自定义全局自动等比例缩放适配句柄,默认nil
启用全局等比例缩放后,所有offset值都会调用该句柄,需注意可能产生的影响。 启用后注意事项如下:
- 屏幕宽度约束不能使用screenWidth约束,需要使用375设计标准
- 尽量不使用screenWidth固定屏幕宽度方式布局,推荐相对于父视图布局
- 只会对offset值生效,其他属性不受影响
- 某个视图如需固定offset值,可指定autoScaleLayout为false关闭该功能
Declaration
Swift
@MainActor public static var autoScaleBlock: ((CGFloat) -> CGFloat)? { get set }
-
快捷启用全局自动等比例缩放布局,自动设置默认autoScaleBlock
框架仅BadgeView和ToolbarView默认关闭等比例缩放布局,采用固定值布局; 其余使用AutoLayout的场景统一使用全局等比例缩放布局开关设置
Declaration
Swift
@MainActor public static var autoScaleLayout: Bool { get set }
-
是否启用全局自动像素取整布局,默认false
Declaration
Swift
@MainActor public static var autoFlatLayout: Bool { get set }
-
当前视图是否自动等比例缩放布局,默认未设置时检查autoScaleBlock
框架仅BadgeView和ToolbarView默认关闭等比例缩放布局,采用固定值布局; 其余使用AutoLayout的场景统一使用全局等比例缩放布局开关设置
Declaration
Swift
@MainActor public var autoScaleLayout: Bool { get set }
-
执行子视图自动布局,自动计算子视图尺寸。需先将视图添加到界面(如设置为tableHeaderView),再调用即可(iOS8+)
Declaration
Swift
@MainActor public func autoLayoutSubviews()
-
设置水平方向抗压缩优先级
Declaration
Swift
@MainActor public var compressionHorizontal: UILayoutPriority { get set }
-
设置垂直方向抗压缩优先级
Declaration
Swift
@MainActor public var compressionVertical: UILayoutPriority { get set }
-
设置水平方向抗拉伸优先级
Declaration
Swift
@MainActor public var huggingHorizontal: UILayoutPriority { get set }
-
设置垂直方向抗拉伸优先级
Declaration
Swift
@MainActor public var huggingVertical: UILayoutPriority { get set }
-
设置视图是否收缩,默认NO为原始值,YES时为收缩值
Declaration
Swift
@MainActor public var isCollapsed: Bool { get set }
-
设置视图是否自动收缩,如image为nil,text为nil、@“"时自动收缩,默认NO
Declaration
Swift
@MainActor public var autoCollapse: Bool { get set }
-
设置视图宽度或高度布局固定时,是否根据尺寸自适应另一边,默认false; 开启时当intrinsicContentSize有值时,会自动添加matchDimension约束
Declaration
Swift
@MainActor public var autoMatchDimension: Bool { get set }
-
设置视图是否隐藏时自动收缩、显示时自动展开,默认NO
Declaration
Swift
@MainActor public var hiddenCollapse: Bool { get set }
-
快速切换视图是否收缩
Declaration
Swift
@MainActor public func toggleCollapsed(_ collapsed: Bool? = nil)
-
快速切换视图是否隐藏
Declaration
Swift
@MainActor public func toggleHidden(_ hidden: Bool? = nil)
-
添加视图的偏移收缩约束,必须先添加才能生效
Declaration
Swift
@MainActor public func addCollapseConstraint(_ constraint: NSLayoutConstraint, offset: CGFloat? = nil)
-
添加视图的有效性收缩约束,必须先添加才能生效
Declaration
Swift
@MainActor public func addCollapseActiveConstraint(_ constraint: NSLayoutConstraint, active: Bool? = nil)
-
添加视图的优先级收缩约束,必须先添加才能生效
Declaration
Swift
@MainActor public func addCollapsePriorityConstraint(_ constraint: NSLayoutConstraint, priority: UILayoutPriority? = nil)
-
移除指定的视图收缩约束
Declaration
Swift
@MainActor public func removeCollapseConstraint(_ constraint: NSLayoutConstraint)
-
移除所有的视图收缩约束
Declaration
Swift
@MainActor public func removeAllCollapseConstraints()
-
父视图居中,可指定偏移距离
Declaration
Swift
@discardableResult @MainActor public func alignCenter( toSuperview offset: CGPoint = .zero, autoScale: Bool? = nil ) -> [NSLayoutConstraint]
Parameters
offset
偏移距离,默认zero
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
约束数组
-
父视图属性居中,可指定偏移距离
Declaration
Swift
@discardableResult @MainActor public func alignAxis( toSuperview axis: NSLayoutConstraint.Attribute, offset: CGFloat = 0, autoScale: Bool? = nil ) -> NSLayoutConstraint
Parameters
axis
居中属性
offset
偏移距离,默认0
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
布局约束
-
与另一视图居中相同,可指定偏移距离
Declaration
Swift
@discardableResult @MainActor public func alignAxis( _ axis: NSLayoutConstraint.Attribute, toView: Any, offset: CGFloat = 0, autoScale: Bool? = nil ) -> NSLayoutConstraint
Parameters
axis
居中属性
toView
另一视图或UILayoutGuide,下同
offset
偏移距离,默认0
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
布局约束
-
与另一视图居中指定比例
Declaration
Swift
@discardableResult @MainActor public func alignAxis( _ axis: NSLayoutConstraint.Attribute, toView: Any, multiplier: CGFloat, autoScale: Bool? = nil ) -> NSLayoutConstraint
Parameters
axis
居中属性
toView
另一视图
multiplier
指定比例
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
布局约束
-
与父视图四条边属性相同,可指定insets距离
Declaration
Swift
@discardableResult @MainActor public func pinEdges( toSuperview insets: UIEdgeInsets = .zero, autoScale: Bool? = nil ) -> [NSLayoutConstraint]
Parameters
insets
指定距离insets,默认zero
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
约束数组
-
与父视图三条边属性距离指定距离
Declaration
Swift
@discardableResult @MainActor public func pinEdges( toSuperview insets: UIEdgeInsets = .zero, excludingEdge: NSLayoutConstraint.Attribute, autoScale: Bool? = nil ) -> [NSLayoutConstraint]
Parameters
insets
指定距离insets
excludingEdge
排除的边
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
约束数组
-
与父视图水平方向两条边属性相同,可指定偏移距离
Declaration
Swift
@discardableResult @MainActor public func pinHorizontal( toSuperview inset: CGFloat = .zero, autoScale: Bool? = nil ) -> [NSLayoutConstraint]
Parameters
inset
偏移距离
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
约束数组
-
与父视图垂直方向两条边属性相同,可指定偏移距离
Declaration
Swift
@discardableResult @MainActor public func pinVertical( toSuperview inset: CGFloat = .zero, autoScale: Bool? = nil ) -> [NSLayoutConstraint]
Parameters
inset
偏移距离
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
约束数组
-
与父视图边属性相同,可指定偏移距离和关系
Declaration
Swift
@discardableResult @MainActor public func pinEdge( toSuperview edge: NSLayoutConstraint.Attribute, inset: CGFloat = .zero, relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required, autoScale: Bool? = nil ) -> NSLayoutConstraint
Parameters
edge
指定边属性
inset
偏移距离,默认0
relation
约束关系,默认相等
priority
约束优先级,默认required
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
布局约束
-
与指定视图边属性相同,可指定偏移距离和关系
Declaration
Swift
@discardableResult @MainActor public func pinEdge( _ edge: NSLayoutConstraint.Attribute, toEdge: NSLayoutConstraint.Attribute, ofView: Any, offset: CGFloat = 0, relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required, autoScale: Bool? = nil ) -> NSLayoutConstraint
Parameters
edge
指定边属性
toEdge
另一视图边属性
ofView
另一视图
offset
偏移距离,默认0
relation
约束关系,默认相等
priority
约束优先级,默认required
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
布局约束
-
父视图安全区域居中,可指定偏移距离。iOS11以下使用Superview实现,下同
Declaration
Swift
@discardableResult @MainActor public func alignCenter( toSafeArea offset: CGPoint, autoScale: Bool? = nil ) -> [NSLayoutConstraint]
Parameters
offset
偏移距离
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
约束数组
-
父视图安全区域属性居中,可指定偏移距离
Declaration
Swift
@discardableResult @MainActor public func alignAxis( toSafeArea axis: NSLayoutConstraint.Attribute, offset: CGFloat = .zero, autoScale: Bool? = nil ) -> NSLayoutConstraint
Parameters
axis
居中属性
offset
偏移距离,默认0
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
布局约束
-
与父视图安全区域四条边属性相同,可指定距离insets
Declaration
Swift
@discardableResult @MainActor public func pinEdges( toSafeArea insets: UIEdgeInsets, autoScale: Bool? = nil ) -> [NSLayoutConstraint]
Parameters
insets
指定距离insets
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
约束数组
-
与父视图安全区域三条边属性距离指定距离
Declaration
Swift
@discardableResult @MainActor public func pinEdges( toSafeArea insets: UIEdgeInsets, excludingEdge: NSLayoutConstraint.Attribute, autoScale: Bool? = nil ) -> [NSLayoutConstraint]
Parameters
insets
指定距离insets
excludingEdge
排除的边
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
约束数组
-
与父视图安全区域水平方向两条边属性相同,可指定偏移距离
Declaration
Swift
@discardableResult @MainActor public func pinHorizontal( toSafeArea inset: CGFloat, autoScale: Bool? = nil ) -> [NSLayoutConstraint]
Parameters
inset
偏移距离
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
约束数组
-
与父视图安全区域垂直方向两条边属性相同,可指定偏移距离
Declaration
Swift
@discardableResult @MainActor public func pinVertical( toSafeArea inset: CGFloat, autoScale: Bool? = nil ) -> [NSLayoutConstraint]
Parameters
inset
偏移距离
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
约束数组
-
与父视图安全区域边属性相同,可指定偏移距离和关系
Declaration
Swift
@discardableResult @MainActor public func pinEdge( toSafeArea edge: NSLayoutConstraint.Attribute, inset: CGFloat = .zero, relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required, autoScale: Bool? = nil ) -> NSLayoutConstraint
Parameters
edge
指定边属性
inset
偏移距离,默认0
relation
约束关系,默认相等
priority
约束优先级,默认required
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
布局约束
-
设置宽高尺寸
Declaration
Swift
@discardableResult @MainActor public func setDimensions( _ size: CGSize, autoScale: Bool? = nil ) -> [NSLayoutConstraint]
Parameters
size
尺寸大小
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
约束数组
-
设置某个尺寸,可指定关系
Declaration
Swift
@discardableResult @MainActor public func setDimension( _ dimension: NSLayoutConstraint.Attribute, size: CGFloat, relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required, autoScale: Bool? = nil ) -> NSLayoutConstraint
Parameters
dimension
尺寸属性
size
尺寸大小
relation
约束关系,默认相等
priority
约束优先级,默认required
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
布局约束
-
与视图自身尺寸属性指定比例,指定关系
Declaration
Swift
@discardableResult @MainActor public func matchDimension( _ dimension: NSLayoutConstraint.Attribute, toDimension: NSLayoutConstraint.Attribute, multiplier: CGFloat, relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required, autoScale: Bool? = nil ) -> NSLayoutConstraint
Parameters
dimension
尺寸属性
toDimension
目标尺寸属性
multiplier
指定比例
relation
约束关系
priority
约束优先级,默认required
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
布局约束
-
与指定视图尺寸属性相同,可指定相差大小和关系
Declaration
Swift
@discardableResult @MainActor public func matchDimension( _ dimension: NSLayoutConstraint.Attribute, toDimension: NSLayoutConstraint.Attribute, ofView: Any, offset: CGFloat = .zero, relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required, autoScale: Bool? = nil ) -> NSLayoutConstraint
Parameters
dimension
尺寸属性
toDimension
目标尺寸属性
ofView
目标视图
offset
相差大小,默认0
relation
约束关系,默认相等
priority
约束优先级,默认required
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
布局约束
-
与指定视图尺寸属性指定比例,可指定关系
Declaration
Swift
@discardableResult @MainActor public func matchDimension( _ dimension: NSLayoutConstraint.Attribute, toDimension: NSLayoutConstraint.Attribute, ofView: Any, multiplier: CGFloat, relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required, autoScale: Bool? = nil ) -> NSLayoutConstraint
Parameters
dimension
尺寸属性
toDimension
目标尺寸属性
ofView
目标视图
multiplier
指定比例
relation
约束关系,默认相等
priority
约束优先级,默认required
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
布局约束
-
与指定视图属性偏移指定距离,指定关系
Declaration
Swift
@discardableResult @MainActor public func constrainAttribute( _ attribute: NSLayoutConstraint.Attribute, toAttribute: NSLayoutConstraint.Attribute, ofView: Any?, offset: CGFloat = .zero, relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required, autoScale: Bool? = nil ) -> NSLayoutConstraint
Parameters
attribute
指定属性
toAttribute
目标视图属性
ofView
目标视图
offset
偏移距离
relation
约束关系
priority
约束优先级,默认required
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
布局约束
-
与指定视图属性指定比例,指定关系
Declaration
Swift
@discardableResult @MainActor public func constrainAttribute( _ attribute: NSLayoutConstraint.Attribute, toAttribute: NSLayoutConstraint.Attribute, ofView: Any?, multiplier: CGFloat, offset: CGFloat = .zero, relation: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority = .required, autoScale: Bool? = nil ) -> NSLayoutConstraint
Parameters
attribute
指定属性
toAttribute
目标视图属性
ofView
目标视图
multiplier
指定比例
offset
偏移距离
relation
约束关系
priority
约束优先级,默认required
autoScale
是否自动等比例缩放偏移值,未设置时检查视图和全局配置
Return Value
布局约束
-
获取添加的与父视图属性的约束,指定关系
Declaration
Swift
@MainActor public func constraint(toSuperview attribute: NSLayoutConstraint.Attribute, relation: NSLayoutConstraint.Relation = .equal) -> NSLayoutConstraint?
Parameters
attribute
指定属性
relation
约束关系
Return Value
布局约束
-
获取添加的与父视图安全区域属性的约束,指定关系
Declaration
Swift
@MainActor public func constraint(toSafeArea attribute: NSLayoutConstraint.Attribute, relation: NSLayoutConstraint.Relation = .equal) -> NSLayoutConstraint?
Parameters
attribute
指定属性
relation
约束关系
Return Value
布局约束
-
获取添加的与指定视图属性的约束,指定关系
Declaration
Swift
@MainActor public func constraint(_ attribute: NSLayoutConstraint.Attribute, toAttribute: NSLayoutConstraint.Attribute, ofView: Any?, relation: NSLayoutConstraint.Relation = .equal) -> NSLayoutConstraint?
Parameters
attribute
指定属性
toAttribute
目标视图属性
ofView
目标视图
relation
约束关系
Return Value
布局约束
-
获取添加的与指定视图属性指定比例的约束,指定关系
Declaration
Swift
@MainActor public func constraint(_ attribute: NSLayoutConstraint.Attribute, toAttribute: NSLayoutConstraint.Attribute, ofView: Any?, multiplier: CGFloat, relation: NSLayoutConstraint.Relation = .equal) -> NSLayoutConstraint?
Parameters
attribute
指定属性
toAttribute
目标视图属性
ofView
目标视图
multiplier
指定比例
relation
约束关系
Return Value
布局约束
-
根据唯一标志获取布局约束
Declaration
Swift
@MainActor public func constraint(identifier: String?) -> NSLayoutConstraint?
Parameters
identifier
唯一标志
Return Value
布局约束
-
最近一批添加或更新的布局约束
Declaration
Swift
@MainActor public var lastConstraints: [NSLayoutConstraint] { get set }
-
获取当前所有约束
Declaration
Swift
@MainActor public private(set) var allConstraints: [NSLayoutConstraint] { get set }
-
移除当前指定约束数组
Declaration
Swift
@MainActor public func removeConstraints(_ constraints: [NSLayoutConstraint]?)
Parameters
constraints
布局约束数组
-
移除当前所有约束
Declaration
Swift
@MainActor public func removeAllConstraints()
-
自动布局调试开关,默认调试打开,正式关闭
Declaration
Swift
@MainActor public static var autoLayoutDebug: Bool { get set }
-
布局调试Key,默认accessibilityIdentifier
Declaration
Swift
@MainActor public var layoutKey: String? { get set }
-
是否自动等比例缩放偏移值,默认未设置时检查视图和全局配置
Declaration
Swift
@MainActor public var autoScaleLayout: Bool { get set }
-
设置偏移值,根据配置自动等比例缩放和取反
Declaration
Swift
@MainActor public var offset: CGFloat { get set }
-
标记是否是相反的约束,一般相对于父视图
Declaration
Swift
@MainActor public var isOpposite: Bool { get set }
-
可收缩约束的收缩偏移值,默认0
Declaration
Swift
@MainActor public var collapseOffset: CGFloat { get set }
-
可收缩约束的原始偏移值,默认为添加收缩约束时的值,未添加时为0
Declaration
Swift
@MainActor public var originalOffset: CGFloat { get set }
-
可收缩约束的收缩优先级,默认defaultLow。注意Required不能修改,否则iOS13以下崩溃
Declaration
Swift
@MainActor public var collapsePriority: UILayoutPriority { get set }
-
可收缩约束的原始优先级,默认为添加收缩约束时的值,未添加时为defaultHigh。注意Required不能修改,否则iOS13以下崩溃
Declaration
Swift
@MainActor public var originalPriority: UILayoutPriority { get set }
-
可收缩约束的原始有效值,默认为添加收缩约束时的有效值,未添加时为false
Declaration
Swift
@MainActor public var originalActive: Bool { get set }
-
约束偏移是否可收缩,默认false,开启时自动初始化originalOffset
Declaration
Swift
@MainActor public var shouldCollapseOffset: Bool { get set }
-
约束有效性是否可收缩,默认false,开启时自动初始化originalActive
Declaration
Swift
@MainActor public var shouldCollapseActive: Bool { get set }
-
约束优先级是否可收缩,默认false,开启时自动初始化originalPriority
Declaration
Swift
@MainActor public var shouldCollapsePriority: Bool { get set }
-
自动布局是否收缩,启用收缩后生效,默认NO为原始值,YES时为收缩值
Declaration
Swift
@MainActor public var isCollapsed: Bool { get set }
-
链式布局对象
Declaration
Swift
@MainActor public var layoutChain: LayoutChain { get }
-
链式布局闭包
Declaration
Swift
@MainActor public func layoutMaker(_ closure: (_ make: LayoutChain) -> Void)
-
批量链式布局闭包
Declaration
Swift
@MainActor public func layoutMaker(_ closure: (_ make: LayoutChain) -> Void)
-
批量对齐布局,适用于间距固定场景,尺寸未设置(可手工指定),若只有一个则间距不生效
Declaration
Swift
@MainActor public func layoutAlong( _ axis: NSLayoutConstraint.Axis, itemSpacing: CGFloat, leadSpacing: CGFloat? = nil, tailSpacing: CGFloat? = nil, itemLength: CGFloat? = nil, equalLength: Bool = false, autoScale: Bool? = nil )
-
批量对齐布局,适用于尺寸固定场景,间距自适应,若只有一个则尺寸不生效
Declaration
Swift
@MainActor public func layoutAlong( _ axis: NSLayoutConstraint.Axis, itemLength: CGFloat, leadSpacing: CGFloat, tailSpacing: CGFloat, autoScale: Bool? = nil )
-
批量对齐布局,用于补齐Along之后该方向上的其他约束
Declaration
Swift
@MainActor public func layoutAlong( _ axis: NSLayoutConstraint.Axis, alignCenter: Bool = false, itemWidth: CGFloat? = nil, leftSpacing: CGFloat? = nil, rightSpacing: CGFloat? = nil, autoScale: Bool? = nil )
-
是否强制iOS13+启用新版样式,默认false,仅iOS15+才启用
Declaration
Swift
@MainActor public static var appearanceEnabled: Bool { get set }
-
设置全局按钮样式属性,nil时系统默认
Declaration
Swift
@MainActor public static var buttonAttributes: [NSAttributedString.Key : Any]? { get set }
-
导航栏iOS13+样式对象,用于自定义样式,默认透明
Declaration
Swift
@MainActor public var appearance: UINavigationBarAppearance { get }
-
手工更新导航栏样式
Declaration
Swift
@MainActor public func updateAppearance()
-
导航栏是否半透明,会重置背景,需优先设置,默认NO;背景色需带有alpha时半透明才会生效
Declaration
Swift
@MainActor public var isTranslucent: Bool { get set }
-
设置前景颜色,包含文字和按钮等
Declaration
Swift
@MainActor public var foregroundColor: UIColor? { get set }
-
单独设置标题颜色,nil时显示前景颜色
Declaration
Swift
@MainActor public var titleAttributes: [NSAttributedString.Key : Any]? { get set }
-
单独设置按钮样式属性,nil时系统默认。仅iOS15+生效,iOS14及以下请使用UIBarButtonItem
Declaration
Swift
@MainActor public var buttonAttributes: [NSAttributedString.Key : Any]? { get set }
-
设置背景颜色(nil时透明),兼容主题颜色,后设置生效
Declaration
Swift
@MainActor public var backgroundColor: UIColor? { get set }
-
设置背景图片(nil时透明),兼容主题图片,后设置生效
Declaration
Swift
@MainActor public var backgroundImage: UIImage? { get set }
-
设置背景是否全透明,默认NO,后设置生效
Declaration
Swift
@MainActor public var backgroundTransparent: Bool { get set }
-
设置阴影颜色(nil时透明),兼容主题颜色,后设置生效
Declaration
Swift
@MainActor public var shadowColor: UIColor? { get set }
-
设置阴影图片(nil时透明),兼容主题图片,后设置生效
Declaration
Swift
@MainActor public var shadowImage: UIImage? { get set }
-
设置返回按钮图片,包含图片和转场Mask图片,自动偏移和系统左侧按钮位置保持一致
Declaration
Swift
@MainActor public var backImage: UIImage? { get set }
-
标签栏iOS13+样式对象,用于自定义样式,默认透明
Declaration
Swift
@MainActor public var appearance: UITabBarAppearance { get }
-
手工更新标签栏样式
Declaration
Swift
@MainActor public func updateAppearance()
-
标签栏是否半透明,会重置背景,需优先设置,默认NO;背景色需带有alpha时半透明才会生效
Declaration
Swift
@MainActor public var isTranslucent: Bool { get set }
-
设置前景颜色,包含文字和按钮等
Declaration
Swift
@MainActor public var foregroundColor: UIColor? { get set }
-
设置背景颜色,兼容主题颜色,后设置生效
Declaration
Swift
@MainActor public var backgroundColor: UIColor? { get set }
-
设置背景图片,兼容主题图片,后设置生效
Declaration
Swift
@MainActor public var backgroundImage: UIImage? { get set }
-
设置背景是否全透明,默认NO,后设置生效
Declaration
Swift
@MainActor public var backgroundTransparent: Bool { get set }
-
设置阴影颜色(nil时透明),兼容主题颜色,后设置生效
Declaration
Swift
@MainActor public var shadowColor: UIColor? { get set }
-
设置阴影图片(nil时透明),兼容主题图片,后设置生效
Declaration
Swift
@MainActor public var shadowImage: UIImage? { get set }
-
工具栏iOS13+样式对象,用于自定义样式,默认透明
Declaration
Swift
@MainActor public var appearance: UIToolbarAppearance { get }
-
手工更新工具栏样式
Declaration
Swift
@MainActor public func updateAppearance()
-
工具栏是否半透明,会重置背景,需优先设置,默认NO;背景色需带有alpha时半透明才会生效
Declaration
Swift
@MainActor public var isTranslucent: Bool { get set }
-
设置前景颜色,包含文字和按钮等
Declaration
Swift
@MainActor public var foregroundColor: UIColor? { get set }
-
单独设置按钮样式属性,nil时系统默认。仅iOS15+生效,iOS14及以下请使用UIBarButtonItem
Declaration
Swift
@MainActor public var buttonAttributes: [NSAttributedString.Key : Any]? { get set }
-
设置背景颜色,兼容主题颜色,后设置生效
Declaration
Swift
@MainActor public var backgroundColor: UIColor? { get set }
-
设置背景图片,兼容主题图片,后设置生效
Declaration
Swift
@MainActor public var backgroundImage: UIImage? { get set }
-
设置背景是否全透明,默认NO,后设置生效
Declaration
Swift
@MainActor public var backgroundTransparent: Bool { get set }
-
设置阴影颜色(nil时透明),兼容主题颜色,后设置生效
Declaration
Swift
@MainActor public var shadowColor: UIColor? { get set }
-
设置阴影图片(nil时透明),兼容主题图片,后设置生效
Declaration
Swift
@MainActor public var shadowImage: UIImage? { get set }
-
自定义工具栏位置,调用后才生效,会自动设置delegate。Bottom时背景自动向下延伸,TopAttached时背景自动向上延伸
Declaration
Swift
@MainActor public var barPosition: UIBarPosition { get set }
-
应用指定导航栏配置
Declaration
Swift
@MainActor public func applyBarAppearance(_ appearance: NavigationBarAppearance)
-
应用指定导航栏样式
Declaration
Swift
@MainActor public func applyBarStyle(_ style: NavigationBarStyle)
-
状态栏样式,默认preferredStatusBarStyle,设置后才会生效
Declaration
Swift
@MainActor public var statusBarStyle: UIStatusBarStyle { get set }
-
状态栏是否隐藏,默认prefersStatusBarHidden,设置后才会生效
Declaration
Swift
@MainActor public var statusBarHidden: Bool { get set }
-
当前导航栏设置,优先级高于style,设置后会在viewWillAppear:自动应用生效
Declaration
Swift
@MainActor public var navigationBarAppearance: NavigationBarAppearance? { get set }
-
当前导航栏样式,默认default,设置后才会在viewWillAppear:自动应用生效
Declaration
Swift
@MainActor public var navigationBarStyle: NavigationBarStyle { get set }
-
导航栏是否隐藏,默认isNavigationBarHidden,设置后才会在viewWillAppear:自动应用生效
Declaration
Swift
@MainActor public var navigationBarHidden: Bool { get set }
-
动态隐藏导航栏,如果当前已经viewWillAppear:时立即执行
Declaration
Swift
@MainActor public func setNavigationBarHidden(_ hidden: Bool, animated: Bool)
-
是否允许修改导航栏样式,默认未设置时child控制器不能修改
Declaration
Swift
@MainActor public var allowsBarAppearance: Bool { get set }
-
标签栏是否隐藏,默认为true,立即生效。如果tabBar一直存在,则用tabBar包裹navBar;如果tabBar只存在主界面,则用navBar包裹tabBar
Declaration
Swift
@MainActor public var tabBarHidden: Bool { get set }
-
动态隐藏标签栏。仅iOS18+支持animated参数,立即生效
Declaration
Swift
@MainActor public func setTabBarHidden(_ hidden: Bool, animated: Bool)
-
工具栏是否隐藏,默认为true。需设置toolbarItems,立即生效
Declaration
Swift
@MainActor public var toolBarHidden: Bool { get set }
-
动态隐藏工具栏。需设置toolbarItems,立即生效
Declaration
Swift
@MainActor public func setToolBarHidden(_ hidden: Bool, animated: Bool)
-
设置视图布局Bar延伸类型,None为不延伸(Bar不覆盖视图),Top|Bottom为顶部|底部延伸,All为全部延伸
Declaration
Swift
@MainActor public var extendedLayoutEdge: UIRectEdge { get set }
-
自适应Bar延伸类型,兼容顶部和底部栏safeArea布局方式,需在viewDidLoad及之后调用生效。开启兼容模式时仅在iOS14及以下生效
Declaration
Swift
@MainActor public func adjustExtendedLayout(compatible: Bool = false)
-
创建Timer,使用target-action,自动CommonModes添加到当前的运行循环中,避免ScrollView滚动时不触发
Declaration
Swift
public static func commonTimer(timeInterval: TimeInterval, target: Any, selector: Selector, userInfo: Any?, repeats: Bool) -> Timer
Parameters
timeInterval
时间
target
目标
selector
方法
userInfo
参数
repeats
是否重复
Return Value
定时器
-
创建Timer,使用block,自动CommonModes添加到当前的运行循环中,避免ScrollView滚动时不触发
Declaration
Swift
public static func commonTimer(timeInterval: TimeInterval, block: @escaping @Sendable (Timer) -> Void, repeats: Bool) -> Timer
Parameters
timeInterval
时间
block
代码块
repeats
是否重复
Return Value
定时器
-
创建Timer,使用主线程block,自动CommonModes添加到当前的运行循环中,避免ScrollView滚动时不触发
Declaration
Swift
public static func safeCommonTimer(timeInterval: TimeInterval, block: @escaping @MainActor @Sendable (Timer) -> Void, repeats: Bool) -> Timer
Parameters
timeInterval
时间
block
代码块
repeats
是否重复
Return Value
定时器
-
创建倒计时定时器
Declaration
Swift
public static func commonTimer(countDown: Int, block: @escaping @MainActor @Sendable (Int) -> Void) -> Timer
Parameters
countDown
倒计时时间
block
每秒执行block,为0时自动停止
Return Value
定时器,可手工停止
-
创建Timer,使用block,需要调用addTimer:forMode:安排到当前的运行循环中(CommonModes避免ScrollView滚动时不触发)。
示例:[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]
Declaration
Swift
public static func timer(timeInterval: TimeInterval, block: @escaping @Sendable (Timer) -> Void, repeats: Bool) -> Timer
Parameters
timeInterval
时间
block
代码块
repeats
是否重复
Return Value
定时器
-
创建Timer,使用block,默认模式安排到当前的运行循环中
Declaration
Swift
public static func scheduledTimer(timeInterval: TimeInterval, block: @escaping @Sendable (Timer) -> Void, repeats: Bool) -> Timer
Parameters
timeInterval
时间
block
代码块
repeats
是否重复
Return Value
定时器
-
暂停NSTimer
Declaration
Swift
public func pauseTimer()
-
开始NSTimer
Declaration
Swift
public func resumeTimer()
-
延迟delay秒后开始NSTimer
Declaration
Swift
public func resumeTimer(afterDelay delay: TimeInterval)
-
从事件句柄初始化
Declaration
Swift
@MainActor public static func gestureRecognizer(block: @escaping @MainActor @Sendable (Base) -> Void) -> Base
-
添加事件句柄,返回监听唯一标志
Declaration
Swift
@discardableResult @MainActor public func addBlock(_ block: @escaping @MainActor @Sendable (Base) -> Void) -> String
-
根据监听唯一标志移除事件句柄,返回是否成功
Declaration
Swift
@discardableResult @MainActor public func removeBlock(identifier: String) -> Bool
-
移除所有事件句柄
Declaration
Swift
@MainActor public func removeAllBlocks()
-
获取当前视图添加的第一个点击手势,默认nil
Declaration
Swift
@MainActor public var tapGesture: UITapGestureRecognizer? { get }
-
添加点击手势事件,可自定义点击高亮句柄等
Declaration
Swift
@discardableResult @MainActor public func addTapGesture(target: Any, action: Selector, customize: (@MainActor (TapGestureRecognizer) -> Void)? = nil) -> UITapGestureRecognizer
-
添加点击手势句柄,可自定义点击高亮句柄等
Declaration
Swift
@discardableResult @MainActor public func addTapGesture(block: @escaping @MainActor @Sendable (UITapGestureRecognizer) -> Void, customize: (@MainActor (TapGestureRecognizer) -> Void)? = nil) -> UITapGestureRecognizer
-
移除指定点击手势,返回是否成功
Declaration
Swift
@discardableResult @MainActor public func removeTapGesture(_ tapGesture: UITapGestureRecognizer) -> Bool
-
移除所有点击手势
Declaration
Swift
@MainActor public func removeAllTapGestures()
-
添加事件句柄,返回监听唯一标志
Declaration
Swift
@discardableResult @MainActor public func addBlock(_ block: @escaping @MainActor @Sendable (Base) -> Void, for controlEvents: UIControl.Event) -> String
-
根据监听唯一标志移除事件句柄
Declaration
Swift
@discardableResult @MainActor public func removeBlock(identifier: String, for controlEvents: UIControl.Event) -> Bool
-
移除所有事件句柄
Declaration
Swift
@discardableResult @MainActor public func removeAllBlocks(for controlEvents: UIControl.Event) -> Bool
-
添加点击事件
Declaration
Swift
@MainActor public func addTouch(target: Any, action: Selector)
-
添加点击句柄,返回监听唯一标志
Declaration
Swift
@discardableResult @MainActor public func addTouch(block: @escaping @MainActor @Sendable (Base) -> Void) -> String
-
根据监听唯一标志移除点击句柄
Declaration
Swift
@discardableResult @MainActor public func removeTouchBlock(identifier: String) -> Bool
-
移除所有点击句柄
Declaration
Swift
@MainActor public func removeAllTouchBlocks()
-
使用指定对象和事件创建Item,支持UIImage|NSString|NSNumber|NSAttributedString等
Declaration
Swift
@MainActor public static func item(object: Any?, target: Any?, action: Selector?) -> Base
-
使用指定对象和句柄创建Item,支持UIImage|NSString|NSNumber|NSAttributedString等
Declaration
Swift
@MainActor public static func item(object: Any?, block: (@MainActor @Sendable (UIBarButtonItem) -> Void)?) -> Base
-
自定义标题样式属性,兼容appearance,默认nil同系统
Declaration
Swift
@MainActor public var titleAttributes: [NSAttributedString.Key : Any]? { get set }
-
设置当前Item触发句柄,nil时清空句柄
Declaration
Swift
@MainActor public func setBlock(_ block: (@MainActor @Sendable (UIBarButtonItem) -> Void)?)
-
快捷设置导航栏标题文字
Declaration
Swift
@MainActor public var title: String? { get set }
-
设置导航栏返回按钮,支持UIBarButtonItem|NSString|UIImage等,nil时显示系统箭头
Declaration
Swift
@MainActor public var backBarItem: Any? { get set }
-
设置导航栏左侧按钮,支持UIBarButtonItem|UIImage等,默认事件为关闭当前页面
Declaration
Swift
@MainActor public var leftBarItem: Any? { get set }
-
设置导航栏右侧按钮,支持UIBarButtonItem|UIImage等,默认事件为关闭当前页面
Declaration
Swift
@MainActor public var rightBarItem: Any? { get set }
-
快捷设置导航栏左侧按钮。注意自定义left按钮之后,系统返回手势失效
Declaration
Swift
@discardableResult @MainActor public func setLeftBarItem(_ object: Any?, target: Any, action: Selector) -> UIBarButtonItem
-
快捷设置导航栏左侧按钮,block事件。注意自定义left按钮之后,系统返回手势失效
Declaration
Swift
@discardableResult @MainActor public func setLeftBarItem(_ object: Any?, block: @escaping @MainActor @Sendable (UIBarButtonItem) -> Void) -> UIBarButtonItem
-
快捷设置导航栏右侧按钮
Declaration
Swift
@discardableResult @MainActor public func setRightBarItem(_ object: Any?, target: Any, action: Selector) -> UIBarButtonItem
-
快捷设置导航栏右侧按钮,block事件
Declaration
Swift
@discardableResult @MainActor public func setRightBarItem(_ object: Any?, block: @escaping @MainActor @Sendable (UIBarButtonItem) -> Void) -> UIBarButtonItem
-
快捷添加导航栏左侧按钮。注意自定义left按钮之后,系统返回手势失效
Declaration
Swift
@discardableResult @MainActor public func addLeftBarItem(_ object: Any?, target: Any, action: Selector) -> UIBarButtonItem
-
快捷添加导航栏左侧按钮,block事件。注意自定义left按钮之后,系统返回手势失效
Declaration
Swift
@discardableResult @MainActor public func addLeftBarItem(_ object: Any?, block: @escaping @MainActor @Sendable (UIBarButtonItem) -> Void) -> UIBarButtonItem
-
快捷添加导航栏右侧按钮
Declaration
Swift
@discardableResult @MainActor public func addRightBarItem(_ object: Any?, target: Any, action: Selector) -> UIBarButtonItem
-
快捷添加导航栏右侧按钮,block事件
Declaration
Swift
@discardableResult @MainActor public func addRightBarItem(_ object: Any?, block: @escaping @MainActor @Sendable (UIBarButtonItem) -> Void) -> UIBarButtonItem
-
Foundation对象编码为json数据,失败时抛异常
Declaration
Swift
public static func jsonEncode(_ object: Any, options: JSONSerialization.WritingOptions = []) throws -> Data
-
json数据解码为Foundation对象,失败时抛异常
Declaration
Swift
public static func jsonDecode(_ data: Data, options: JSONSerialization.ReadingOptions = []) throws -> Any
-
json数据解码为Foundation对象
Declaration
Swift
public var jsonDecode: Any? { get }
-
base64编码
Declaration
Swift
public var base64Encode: Data { get }
-
base64解码
Declaration
Swift
public var base64Decode: Data? { get }
-
Foundation对象编码为json字符串
Declaration
Swift
public static func jsonEncode(_ object: Any, options: JSONSerialization.WritingOptions = []) -> String?
-
json字符串解码为Foundation对象
Declaration
Swift
public var jsonDecode: Any? { get }
-
base64编码
Declaration
Swift
public var base64Encode: String? { get }
-
base64解码
Declaration
Swift
public var base64Decode: String? { get }
-
Unicode中文编码,将中文转换成Unicode字符串(如\u7E8C)
Declaration
Swift
public var unicodeEncode: String { get }
-
Unicode中文解码,将Unicode字符串(如\u7E8C)转换成中文
Declaration
Swift
public var unicodeDecode: String { get }
-
url参数编码,适用于query参数编码
示例:http://test.com?id=我是中文 => http%3A%2F%2Ftest.com%3Fid%3D%E6%88%91%E6%98%AF%E4%B8%AD%E6%96%87
Declaration
Swift
public var urlEncodeComponent: String? { get }
-
url参数解码,适用于query参数解码
示例:http%3A%2F%2Ftest.com%3Fid%3D%E6%88%91%E6%98%AF%E4%B8%AD%E6%96%87 => http://test.com?id=我是中文
Declaration
Swift
public var urlDecodeComponent: String? { get }
-
url编码,适用于整个url编码
示例:http://test.com?id=我是中文 => http://test.com?id=%E6%88%91%E6%98%AF%E4%B8%AD%E6%96%87
Declaration
Swift
public var urlEncode: String? { get }
-
url解码,适用于整个url解码
示例:http://test.com?id=%E6%88%91%E6%98%AF%E4%B8%AD%E6%96%87 => http://test.com?id=我是中文
Declaration
Swift
public var urlDecode: String? { get }
-
字典编码为URL参数字符串
Declaration
Swift
public static func queryEncode(_ dict: [String : Any]) -> String
-
URL参数字符串解码为字典,支持完整URL
Declaration
Swift
public var queryDecode: [String : String] { get }
-
md5编码
Declaration
Swift
public var md5Encode: String { get }
-
中文转拼音
Declaration
Swift
public var pinyinString: String { get }
-
中文转拼音并进行比较
Declaration
Swift
public func pinyinCompare(_ string: String) -> ComparisonResult
-
是否包含Emoji表情
Declaration
Swift
public var containsEmoji: Bool { get }
-
过滤JSON解码特殊字符
兼容\uD800-\uDFFF引起JSON解码报错3840问题,不报错时无需调用 规则:只允许以\uD800-\uDBFF高位开头,紧跟\uDC00-\uDFFF低位;其他全不允许 参考:https://github.com/SBJson/SBJson/blob/trunk/Classes/SBJson5StreamTokeniser.m
Declaration
Swift
public var escapeJson: String { get }
-
获取当前query的参数字典,不含空值
Declaration
Swift
public var queryParameters: [String : String] { get }
-
获取基准URI字符串,不含path|query|fragment等,包含scheme|host|port等
Declaration
Swift
public var baseURI: String? { get }
-
获取路径URI字符串,不含host|port等,包含path|query|fragment等
Declaration
Swift
public var pathURI: String? { get }
-
添加query参数字典并返回新的URL
Declaration
Swift
public func appendingQueryParameters(_ parameters: [String : String]) -> URL
-
获取指定query参数值
Declaration
Swift
public func queryValue(for key: String) -> String?
-
计算动态布局视图指定宽度时的高度。使用AutoLayout必须约束完整,不使用AutoLayout会调用view的sizeThatFits:方法
Declaration
Swift
@MainActor public func layoutHeight(width: CGFloat) -> CGFloat
-
计算动态布局视图指定高度时的宽度。使用AutoLayout必须约束完整,不使用AutoLayout会调用view的sizeThatFits:方法
Declaration
Swift
@MainActor public func layoutWidth(height: CGFloat) -> CGFloat
-
计算动态AutoLayout布局视图指定宽度时的高度。
注意调用后会重置superview和frame,一般用于未添加到superview时的场景,cell等请使用DynamicLayout
Declaration
Swift
@MainActor public func dynamicHeight( width: CGFloat, maxYViewExpanded: Bool = false, maxYViewPadding: CGFloat = 0, maxYView: UIView? = nil ) -> CGFloat
Parameters
width
指定宽度
maxYViewExpanded
最大Y视图是否撑开布局,需布局约束完整。默认false,无需撑开布局
maxYViewPadding
最大Y视图的底部内边距,maxYViewExpanded为true时不起作用,默认0
maxYView
指定最大Y视图,默认nil
Return Value
高度
-
计算动态AutoLayout布局视图指定高度时的宽度。
注意调用后会重置superview和frame,一般用于未添加到superview时的场景,cell等请使用DynamicLayout
Declaration
Swift
@MainActor public func dynamicWidth( height: CGFloat, maxYViewExpanded: Bool = false, maxYViewPadding: CGFloat = 0, maxYView: UIView? = nil ) -> CGFloat
Parameters
height
指定高度
maxYViewExpanded
最大Y视图是否撑开布局(横向时为X),需布局约束完整。默认false,无需撑开布局
maxYViewPadding
最大Y视图的底部内边距(横向时为X),maxYViewExpanded为true时不起作用,默认0
maxYView
指定最大Y视图(横向时为X),默认nil
Return Value
宽度
-
获取动态布局视图类的尺寸,可固定宽度或高度
Declaration
Swift
@_spi(FW) @MainActor public func dynamicSize<T: UIView & DynamicLayoutViewProtocol>( viewClass: T.Type, viewIdentifier: String, width fixedWidth: CGFloat = 0, height fixedHeight: CGFloat = 0, configuration: (T) -> Void ) -> CGSize
Parameters
viewClass
视图类
viewIdentifier
视图标记
fixedWidth
固定宽度,默认0不固定
fixedHeight
固定高度,默认0不固定
configuration
布局cell句柄,内部不会持有Block,不需要weak
Return Value
尺寸
-
如果用来确定Cell所需高度的View是唯一的,请把此值设置为YES,可提升一定的性能
Declaration
Swift
@MainActor public var maxYViewFixed: Bool { get set }
-
最大Y视图的底部内边距,可避免新创建View来撑开Cell,默认0
Declaration
Swift
@MainActor public var maxYViewPadding: CGFloat { get set }
-
最大Y视图是否撑开布局,需布局约束完整。默认NO,无需撑开布局;YES时padding不起作用
Declaration
Swift
@MainActor public var maxYViewExpanded: Bool { get set }
-
免注册创建UITableViewCell,内部自动处理缓冲池,可指定style类型和reuseIdentifier
Declaration
Swift
@MainActor public static func cell( tableView: UITableView, style: UITableViewCell.CellStyle = .default, reuseIdentifier: String? = nil ) -> Base
-
根据配置自动计算cell高度,可指定key使用缓存,子类可重写
Declaration
Swift
@MainActor public static func height( tableView: UITableView, cacheBy key: AnyHashable? = nil, configuration: (Base) -> Void ) -> CGFloat
-
如果用来确定HeaderFooterView所需高度的View是唯一的,请把此值设置为YES,可提升一定的性能
Declaration
Swift
@MainActor public var maxYViewFixed: Bool { get set }
-
最大Y视图的底部内边距,可避免新创建View来撑开HeaderFooterView,默认0
Declaration
Swift
@MainActor public var maxYViewPadding: CGFloat { get set }
-
最大Y视图是否撑开布局,需布局约束完整。默认NO,无需撑开布局;YES时padding不起作用
Declaration
Swift
@MainActor public var maxYViewExpanded: Bool { get set }
-
免注册alloc创建UITableViewHeaderFooterView,内部自动处理缓冲池,指定reuseIdentifier
Declaration
Swift
@MainActor public static func headerFooterView( tableView: UITableView, reuseIdentifier: String? = nil ) -> Base
-
根据配置自动计算cell高度,可指定key使用缓存,子类可重写
Declaration
Swift
@MainActor public static func height( tableView: UITableView, type: HeaderFooterViewType, cacheBy key: AnyHashable? = nil, configuration: (Base) -> Void ) -> CGFloat
-
手工清空高度缓存,用于高度发生变化的情况
Declaration
Swift
@MainActor public func clearHeightCache()
-
指定key设置cell高度缓存,如willDisplayCell调用,height为cell.frame.size.height,设置为0时清除缓存
Declaration
Swift
@MainActor public func setCellHeightCache(_ height: CGFloat, for key: AnyHashable)
-
指定key获取cell缓存高度,如estimatedHeightForRow调用,默认值automaticDimension
Declaration
Swift
@MainActor public func cellHeightCache(for key: AnyHashable) -> CGFloat
-
指定key设置HeaderFooter高度缓存,如willDisplayHeaderFooter调用,height为view.frame.size.height,设置为0时清除缓存
Declaration
Swift
@MainActor public func setHeaderFooterHeightCache(_ height: CGFloat, type: HeaderFooterViewType, for key: AnyHashable)
-
指定key获取HeaderFooter缓存高度,如estimatedHeightForHeaderFooter调用,默认值automaticDimension
Declaration
Swift
@MainActor public func headerFooterHeightCache(_ type: HeaderFooterViewType, for key: AnyHashable) -> CGFloat
-
免注册创建UITableViewCell,内部自动处理缓冲池,可指定style类型和reuseIdentifier
Declaration
Swift
@MainActor public func cell<T: UITableViewCell>( of cellClass: T.Type, style: UITableViewCell.CellStyle = .default, reuseIdentifier: String? = nil ) -> T
-
获取 Cell 需要的高度,可指定key使用缓存
Declaration
Swift
@MainActor public func height<T: UITableViewCell>( cellClass: T.Type, cacheBy key: AnyHashable? = nil, configuration: (T) -> Void ) -> CGFloat
Parameters
cellClass
cell class
key
使用 key 做缓存标识,如数据唯一id,对象hash等,默认nil
configuration
布局 cell,内部不会拥有 Block,不需要 __weak
Return Value
cell高度
-
免注册alloc创建UITableViewHeaderFooterView,内部自动处理缓冲池,指定reuseIdentifier
Declaration
Swift
@MainActor public func headerFooterView<T: UITableViewHeaderFooterView>( of headerFooterViewClass: T.Type, reuseIdentifier: String? = nil ) -> T
-
获取 HeaderFooter 需要的高度,可指定key使用缓存
Declaration
Swift
@MainActor public func height<T: UITableViewHeaderFooterView>( headerFooterViewClass: T.Type, type: HeaderFooterViewType, cacheBy key: AnyHashable? = nil, configuration: (T) -> Void ) -> CGFloat
Parameters
headerFooterViewClass
HeaderFooter class
type
HeaderFooter类型,Header 或者 Footer
key
使用 key 做缓存标识,如数据唯一id,对象hash等,默认nil
configuration
布局 HeaderFooter,内部不会拥有 Block,不需要 __weak
Return Value
HeaderFooter高度
-
如果用来确定Cell所需高度的View是唯一的,请把此值设置为YES,可提升一定的性能
Declaration
Swift
@MainActor public var maxYViewFixed: Bool { get set }
-
最大Y视图的底部内边距(横向滚动时为X),可避免新创建View来撑开Cell,默认0
Declaration
Swift
@MainActor public var maxYViewPadding: CGFloat { get set }
-
最大Y视图是否撑开布局(横向滚动时为X),需布局约束完整。默认NO,无需撑开布局;YES时padding不起作用
Declaration
Swift
@MainActor public var maxYViewExpanded: Bool { get set }
-
免注册创建UICollectionViewCell,内部自动处理缓冲池,指定reuseIdentifier
Declaration
Swift
@MainActor public static func cell( collectionView: UICollectionView, indexPath: IndexPath, reuseIdentifier: String? = nil ) -> Base
-
根据配置自动计算view大小,可固定宽度或高度,可指定key使用缓存,子类可重写
Declaration
Swift
@MainActor public static func size( collectionView: UICollectionView, width: CGFloat = 0, height: CGFloat = 0, cacheBy key: AnyHashable? = nil, configuration: (Base) -> Void ) -> CGSize
-
如果用来确定ReusableView所需尺寸的View是唯一的,请把此值设置为YES,可提升一定的性能
Declaration
Swift
@MainActor public var maxYViewFixed: Bool { get set }
-
最大Y尺寸视图的底部内边距(横向滚动时为X),可避免新创建View来撑开ReusableView,默认0
Declaration
Swift
@MainActor public var maxYViewPadding: CGFloat { get set }
-
最大Y视图是否撑开布局(横向滚动时为X),需布局约束完整。默认NO,无需撑开布局;YES时padding不起作用
Declaration
Swift
@MainActor public var maxYViewExpanded: Bool { get set }
-
免注册alloc创建UICollectionReusableView,内部自动处理缓冲池,指定reuseIdentifier
Declaration
Swift
@MainActor public static func reusableView( collectionView: UICollectionView, kind: String, indexPath: IndexPath, reuseIdentifier: String? = nil ) -> Base
-
根据配置自动计算view大小,可固定宽度或高度,可指定key使用缓存,子类可重写
Declaration
Swift
@MainActor public static func size( collectionView: UICollectionView, width: CGFloat = 0, height: CGFloat = 0, kind: String, cacheBy key: AnyHashable? = nil, configuration: (Base) -> Void ) -> CGSize
-
手工清空尺寸缓存,用于尺寸发生变化的情况
Declaration
Swift
@MainActor public func clearSizeCache()
-
指定key设置cell尺寸缓存,设置为zero时清除缓存
Declaration
Swift
@MainActor public func setCellSizeCache(_ size: CGSize, for key: AnyHashable)
-
指定key获取cell缓存尺寸,默认值automaticSize
Declaration
Swift
@MainActor public func cellSizeCache(for key: AnyHashable) -> CGSize
-
指定key设置ReusableView尺寸缓存,设置为zero时清除缓存
Declaration
Swift
@MainActor public func setReusableViewSizeCache(_ size: CGSize, kind: String, for key: AnyHashable)
-
指定key获取ReusableView缓存尺寸,默认值automaticSize
Declaration
Swift
@MainActor public func reusableViewSizeCache(_ kind: String, for key: AnyHashable) -> CGSize
-
免注册创建UICollectionViewCell,内部自动处理缓冲池,指定reuseIdentifier
Declaration
Swift
@MainActor public func cell<T: UICollectionViewCell>( of cellClass: T.Type, indexPath: IndexPath, reuseIdentifier: String? = nil ) -> T
-
获取 Cell 需要的尺寸,可固定宽度或高度,可指定key使用缓存
Declaration
Swift
@MainActor public func size<T: UICollectionViewCell>( cellClass: T.Type, width: CGFloat = 0, height: CGFloat = 0, cacheBy key: AnyHashable? = nil, configuration: (T) -> Void ) -> CGSize
Parameters
cellClass
cell类
width
固定宽度,默认0不固定
height
固定高度,默认0不固定
key
使用 key 做缓存标识,如数据唯一id,对象hash等,默认nil
configuration
布局cell句柄,内部不会拥有Block,不需要__weak
Return Value
cell尺寸
-
免注册alloc创建UICollectionReusableView,内部自动处理缓冲池,指定reuseIdentifier
Declaration
Swift
@MainActor public func reusableView<T: UICollectionReusableView>( of reusableViewClass: T.Type, kind: String, indexPath: IndexPath, reuseIdentifier: String? = nil ) -> T
-
获取 ReusableView 需要的尺寸,可固定宽度或高度,可指定key使用缓存
Declaration
Swift
@MainActor public func size<T: UICollectionReusableView>( reusableViewClass: T.Type, width: CGFloat = 0, height: CGFloat = 0, kind: String, cacheBy key: AnyHashable? = nil, configuration: (T) -> Void ) -> CGSize
Parameters
reusableViewClass
ReusableView class
width
固定宽度,默认0不固定
height
固定高度,默认0不固定
kind
ReusableView类型,Header 或者 Footer
key
使用 key 做缓存标识,如数据唯一id,对象hash等,默认nil
configuration
布局 ReusableView,内部不会拥有 Block,不需要 __weak
Return Value
ReusableView尺寸
-
执行加锁(支持任意对象),等待信号量,自动创建信号量
Declaration
Swift
public func lock()
-
执行解锁(支持任意对象),发送信号量,自动创建信号量
Declaration
Swift
public func unlock()
-
延迟创建锁,默认SemaphoreLock
Declaration
Swift
public var locking: LockingProtocol { get set }
-
延迟创建队列,默认串行队列
Declaration
Swift
public var queue: DispatchQueue { get set }
-
通用互斥锁方法
Declaration
Swift
public static func synchronized(_ closure: () -> Void)
-
通用互斥锁方法,返回指定对象
Declaration
Swift
public static func synchronized<T>(_ closure: () -> T) -> T
-
通用互斥锁方法
Declaration
Swift
public func synchronized(_ closure: () -> Void)
-
通用互斥锁方法,返回指定对象
Declaration
Swift
public func synchronized<T>(_ closure: () -> T) -> T
-
同一个token仅执行一次block,对象范围
Declaration
Swift
public func dispatchOnce( _ token: String, closure: () -> Void )
-
延迟delay秒后主线程执行,返回可取消的block,对象范围
Declaration
Swift
@discardableResult public func performBlock( _ block: @escaping @MainActor @Sendable (Base) -> Void, afterDelay delay: TimeInterval ) -> Any where Base: Sendable
-
延迟delay秒后后台线程执行,返回可取消的block,对象范围
Declaration
Swift
@discardableResult public func performBlock( inBackground block: @escaping @Sendable (Base) -> Void, afterDelay delay: TimeInterval ) -> Any where Base: Sendable
-
延迟delay秒后指定线程执行,返回可取消的block,对象范围
Declaration
Swift
@discardableResult public func performBlock( _ block: @escaping @Sendable (Base) -> Void, on queue: DispatchQueue, afterDelay delay: TimeInterval ) -> Any where Base: Sendable
-
同一个token仅执行一次block,全局范围
Declaration
Swift
public static func dispatchOnce( _ token: AnyHashable, closure: () -> Void )
-
延迟delay秒后主线程执行,返回可取消的block,全局范围
Declaration
Swift
@discardableResult public static func performBlock( _ block: @escaping @MainActor @Sendable () -> Void, afterDelay delay: TimeInterval ) -> Any
-
延迟delay秒后后台线程执行,返回可取消的block,全局范围
Declaration
Swift
@discardableResult public static func performBlock( inBackground block: @escaping @Sendable () -> Void, afterDelay delay: TimeInterval ) -> Any
-
延迟delay秒后指定线程执行,返回可取消的block,全局范围
Declaration
Swift
@discardableResult public static func performBlock( _ block: @escaping @Sendable () -> Void, on queue: 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 @Sendable (@escaping @Sendable () -> Void) -> Void )
-
重试方式执行异步block,直至成功或者次数为0(小于0不限)或者超时(小于等于0不限),完成后回调completion。block必须调用completionHandler,参数示例:重试4次|超时8秒|延迟2秒
Declaration
Swift
public static func performBlock( _ block: @escaping @Sendable (@escaping @Sendable (Bool, Any?) -> Void) -> Void, completion: @escaping @Sendable (Bool, Any?) -> Void, retryCount: Int, timeoutInterval: TimeInterval, delayInterval: @escaping @Sendable (Int) -> TimeInterval, isCancelled: (@Sendable () -> Bool)? = nil )
-
执行轮询block任务,返回任务Id可取消
Declaration
Swift
@discardableResult public static func performTask(_ task: @escaping @Sendable () -> Void, start: TimeInterval, interval: TimeInterval, repeats: Bool, async: Bool) -> String
-
指定任务Id取消轮询任务
Declaration
Swift
public static func cancelTask(_ taskId: String?)
-
当前时间戳,没有设置过返回本地时间戳,可同步设置服务器时间戳,同步后调整手机时间不影响
Declaration
Swift
public static var currentTime: TimeInterval { get set }
-
通用DateFormatter对象,默认系统时区,使用时需先指定dateFormat,可自定义
Declaration
Swift
public static var dateFormatter: DateFormatter { get set }
-
从字符串初始化日期,自定义格式(默认yyyy-MM-dd HH:mm:ss)
Declaration
Swift
public static func date(string: String, format: String = "yyyy-MM-dd HH:mm:ss") -> Date?
-
转化为字符串,格式:yyyy-MM-dd HH:mm:ss
Declaration
Swift
public var stringValue: String { get }
-
转化为字符串,自定义格式
Declaration
Swift
public func string(format: String) -> String
-
格式化时长,格式"00:00"或"00:00:00"
Declaration
Swift
public static func formatDuration(_ duration: TimeInterval, hasHour: Bool) -> String
-
格式化16位、13位时间戳为10位(秒)
Declaration
Swift
public static func formatTimestamp(_ timestamp: TimeInterval) -> TimeInterval
-
解析服务器时间戳,参数为接口响应Header的Date字段,解析失败返回0
Declaration
Swift
public static func formatServerDate(_ dateString: String) -> TimeInterval
-
是否是闰年
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
-
快捷创建NumberFormatter对象,默认numberStyle为decimal
Declaration
Swift
public static func numberFormatter( _ digit: Int = 2, roundingMode: NumberFormatter.RoundingMode = .halfUp, fractionZero: Bool = false, groupingSeparator: String = "", currencySymbol: String = "" ) -> NumberFormatter
Parameters
digit
保留小数位数,默认2,示例:1234.5678 => 1234.57
roundingMode
取整模式,默认四舍五入,示例:1234.5678 => 1234.57
fractionZero
是否保留小数末尾0(示例:1234.5012 => 1234.50),默认false去掉末尾0(示例:1234.5012 => 1234.5)
groupingSeparator
分组分隔符,默认为空,示例:1234.5678 => 1,234.57
currencySymbol
货币符号,默认为空,指定后numberStyle为currency,示例:1234.5678 => $1234.57
Return Value
NumberFormatter对象
-
快捷四舍五入格式化为字符串,默认numberStyle为decimal
Declaration
Swift
public func roundString( _ digit: Int = 2, fractionZero: Bool = false, groupingSeparator: String = "", currencySymbol: String = "" ) -> String
Parameters
digit
保留小数位数,默认2,示例:1234.5678 => 1234.57
fractionZero
是否保留小数末尾0(示例:1234.5012 => 1234.50),默认false去掉末尾0(示例:1234.5012 => 1234.5)
groupingSeparator
分组分隔符,默认为空,示例:1234.5678 => 1,234.57
currencySymbol
货币符号,默认为空,指定后numberStyle为currency,示例:1234.5678 => $1234.57
Return Value
格式化字符串
-
快捷取上整格式化为字符串,默认numberStyle为decimal
Declaration
Swift
public func ceilString( _ digit: Int = 2, fractionZero: Bool = false, groupingSeparator: String = "", currencySymbol: String = "" ) -> String
Parameters
digit
保留小数位数,默认2,示例:1234.5678 => 1234.57
fractionZero
是否保留小数末尾0(示例:1234.8912 => 1234.90),默认false去掉末尾0(示例:1234.8912 => 1234.9)
groupingSeparator
分组分隔符,默认为空,示例:1234.5678 => 1,234.57
currencySymbol
货币符号,默认为空,指定后numberStyle为currency,示例:1234.5678 => $1234.57
Return Value
格式化字符串
-
快捷取下整格式化为字符串,默认numberStyle为decimal
Declaration
Swift
public func floorString( _ digit: Int = 2, fractionZero: Bool = false, groupingSeparator: String = "", currencySymbol: String = "" ) -> String
Parameters
digit
保留小数位数,默认2,示例:1234.5678 => 1234.56
fractionZero
是否保留小数末尾0(示例:1234.9012 => 1234.90),默认false去掉末尾0(示例:1234.9012 => 1234.9)
groupingSeparator
分组分隔符,默认为空,示例:1234.5678 => 1,234.56
currencySymbol
货币符号,默认为空,指定后numberStyle为currency,示例:1234.5678 => $1234.56
Return Value
格式化字符串
-
将波浪线相对路径展开为绝对路径
Declaration
Swift
public var expandingTildePath: String { get }
-
将绝对路径替换为波浪线相对路径
Declaration
Swift
public var abbreviatingTildePath: String { get }
-
附加路径组件
Declaration
Swift
public func appendingPath(_ component: String) -> String
-
附加路径组件数组
Declaration
Swift
public func appendingPath(_ components: [String]) -> String
-
附加路径后缀,失败时返回空
Declaration
Swift
public func appendingPathExtension(_ ext: String) -> String
-
计算多行字符串指定字体、指定属性在指定绘制区域内所占尺寸
Declaration
Swift
public func size( font: UIFont, drawSize: CGSize = CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude), attributes: [NSAttributedString.Key: Any]? = nil ) -> CGSize
-
格式化文件大小为".0K/.1M/.1G"
Declaration
Swift
public static func sizeString(_ aFileSize: UInt64) -> String
-
是否匹配正则表达式,示例:^[a-zA-Z0-9_\u4e00-\u9fa5]{4,14}$
Declaration
Swift
public func matchesRegex(_ regex: String) -> Bool
-
安全截取字符串。解决末尾半个Emoji问题(半个Emoji调UTF8String为NULL,导致MD5签名等失败)
@param index 目标索引
Declaration
Swift
public func emojiSubstring(_ index: Int) -> 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
-
正则匹配回调
Declaration
Swift
public func regexMatches(_ regex: String, reverse: Bool = true, block: (NSRange) -> Void)
Parameters
regex
正则表达式
reverse
匹配结果是否反向,默认true
block
回调句柄。正向时range从小到大,反向时从大至小,方便replace
-
检测链接并回调,NSAttributedString调用时请使用string防止range越界
Declaration
Swift
public func detectLinks(types: NSTextCheckingTypes? = nil, block: (NSTextCheckingResult, String, UnsafeMutablePointer<ObjCBool>) -> Void)
-
转义Html,如"a<“转义为"a<”
Declaration
Swift
public var escapeHtml: String { get }
-
是否符合验证器
Declaration
Swift
public func isValid(_ validator: Validator<String>) -> Bool
-
搜索路径
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
@discardableResult public static func createDirectory(atPath: String, attributes: [FileAttributeKey : Any]? = nil) -> Bool
-
递归删除目录|文件,返回是否成功
Declaration
Swift
@discardableResult public static func removeItem(atPath: String) -> Bool
-
移动目录|文件,返回是否成功
Declaration
Swift
@discardableResult public static func moveItem(atPath: String, toPath: String) -> Bool
-
查询目录|文件是否存在
Declaration
Swift
public static func fileExists(atPath: String, isDirectory: Bool? = nil) -> Bool
-
获取文件大小,单位:B
Declaration
Swift
public static func fileSize(_ filePath: String) -> UInt64
-
获取目录大小,单位:B
Declaration
Swift
public static func folderSize(_ folderPath: String) -> UInt64
-
将路径标记为禁止iCloud备份
Declaration
Swift
@discardableResult public static func skipBackup(_ path: String) -> Bool
-
获取全局样式(index为0的属性)
Declaration
Swift
public var attributes: [NSAttributedString.Key : Any]? { get }
-
NSAttributedString对象转换为html字符串
Declaration
Swift
public func htmlString() -> String?
-
计算所占尺寸,需设置Font等
Declaration
Swift
public var textSize: CGSize { get }
-
计算在指定绘制区域内所占尺寸,需设置Font等
Declaration
Swift
public func textSize(drawSize: CGSize) -> CGSize
-
html字符串转换为NSAttributedString对象。如需设置默认字体和颜色,请使用addAttributes方法或附加CSS样式
Declaration
Swift
public static func attributedString(htmlString: String) -> Base?
-
图片转换为NSAttributedString对象,可实现行内图片样式。其中bounds.x会设置为间距,y常用算法:(font.capHeight - image.size.height) / 2.0
Declaration
Swift
public static func attributedString(image: UIImage?, bounds: CGRect) -> NSAttributedString
-
快速创建NSAttributedString并指定单个高亮部分文字和样式,链接设置NSLinkAttributeName|URL属性即可
Declaration
Swift
public static func attributedString(string: String, attributes: [NSAttributedString.Key : Any]?, highlight: String, highlightAttributes: [NSAttributedString.Key : Any]?) -> NSAttributedString
-
快速创建NSAttributedString并指定所有高亮部分文字和样式,链接设置NSLinkAttributeName|URL属性即可
Declaration
Swift
public static func attributedString(string: String, attributes: [NSAttributedString.Key : Any]?, highlights: [String : [NSAttributedString.Key : Any]]) -> NSAttributedString
-
快速创建NSAttributedString,自定义字体和颜色
Declaration
Swift
public static func attributedString(_ string: String, font: UIFont?, textColor: UIColor? = nil, attributes: [NSAttributedString.Key : Any]? = nil) -> Base
-
快速创建NSAttributedString,自定义字体、颜色、行高、对齐方式和换行模式
Declaration
Swift
public static func attributedString(_ string: String, font: UIFont?, textColor: UIColor?, lineHeight: CGFloat, textAlignment: NSTextAlignment = .left, lineBreakMode: NSLineBreakMode = .byWordWrapping, attributes: [NSAttributedString.Key : Any]? = nil) -> Base
-
快速创建指定行高、对齐方式和换行模式的段落样式对象
Declaration
Swift
public static func paragraphStyle(lineHeight: CGFloat, textAlignment: NSTextAlignment = .left, lineBreakMode: NSLineBreakMode = .byWordWrapping) -> NSMutableParagraphStyle
-
html字符串转换为NSAttributedString对象,可设置默认系统字体和颜色(附加CSS方式)
Declaration
Swift
public static func attributedString(htmlString string: String, defaultAttributes: [NSAttributedString.Key : Any]?) -> Base?
-
html字符串转换为NSAttributedString主题对象,可设置默认系统字体和动态颜色,详见ThemeObject
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
-
当指定属性不存在时添加默认值,默认整个range
Declaration
Swift
public func addDefaultAttribute(_ name: NSAttributedString.Key, value: Any, range: NSRange? = nil)
-
设置指定段落样式keyPath对应值,默认整个range
Declaration
Swift
public func setParagraphStyleValue<Value>(_ keyPath: ReferenceWritableKeyPath<NSMutableParagraphStyle, Value>, value: Value, range: NSRange? = nil)
-
生成App Store外部URL
@param appId 应用Id @return NSURL
Declaration
Swift
public static func appStoreURL(_ appId: String) -> URL
-
生成苹果地图地址外部URL
@param addr 显示地址,格式latitude,longitude或搜索地址 @param options 可选附加参数,如[“ll”: “latitude,longitude”, “z”: “14”] @return NSURL
Declaration
Swift
public static func appleMapsURL(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(saddr: String?, daddr: String?, options: [AnyHashable : Any]? = nil) -> URL?
-
生成谷歌地图外部URL
@param addr 显示地址,格式latitude,longitude或搜索地址 @param options 可选附加参数,如[“query_place_id”: “”] @return NSURL
Declaration
Swift
public static func googleMapsURL(addr: String?, options: [AnyHashable : Any]? = nil) -> URL?
-
生成谷歌地图导航外部URL
@param saddr 导航起始点,格式latitude,longitude或搜索地址 @param daddr 导航结束点,格式latitude,longitude或搜索地址 @param mode 导航模式,支持driving|transit|bicycling|walking @param options 可选附加参数,如[“origin_place_id”: “”] @return NSURL
Declaration
Swift
public static func googleMapsURL(saddr: String?, daddr: String?, mode: String? = nil, options: [AnyHashable : Any]? = nil) -> URL?
-
生成外部URL,需配置对应URL SCHEME
@param string 外部主URL @param params 附加参数 @return NSURL
Declaration
Swift
public static func vendorURL(_ string: String, params: [AnyHashable : Any]? = nil) -> URL?
-
是否禁止网络代理抓包,不影响App请求,默认false
Declaration
Swift
public static var httpProxyDisabled: Bool { get set }
-
获取手机网络代理,可能为空
Declaration
Swift
public static var httpProxyString: String? { get }
-
从standard读取对象,支持unarchive对象
Declaration
Swift
public static func object(forKey: String) -> Any?
-
保存对象到standard,支持archive对象
Declaration
Swift
public static func setObject(_ object: Any?, forKey: String)
-
读取对象,支持unarchive对象
Declaration
Swift
public func object(forKey: String) -> Any?
-
保存对象,支持archive对象
Declaration
Swift
public func setObject(_ object: Any?, forKey: String)
-
从standard解档对象,兼容NSCoding和AnyArchivable
Declaration
Swift
public static func archivableObject(forKey: String) -> Any?
-
归档对象到standard,兼容NSCoding和AnyArchivable
Declaration
Swift
public static func setArchivableObject(_ object: Any?, forKey: String)
-
解档对象,兼容NSCoding和AnyArchivable
Declaration
Swift
public func archivableObject(forKey: String) -> Any?
-
归档对象,兼容NSCoding和AnyArchivable
Declaration
Swift
public func setArchivableObject(_ object: Any?, forKey: String)
-
是否启用键盘管理(自动滚动),默认NO
Declaration
Swift
@MainActor public var keyboardManager: Bool { get set }
-
设置输入框和键盘的空白间距,默认10.0
Declaration
Swift
@MainActor public var keyboardDistance: CGFloat { get set }
-
设置输入框和键盘的空白间距句柄,参数为键盘高度、输入框高度,优先级高,默认nil
Declaration
Swift
@MainActor public var keyboardDistanceBlock: ((_ keyboardHeight: CGFloat, _ height: CGFloat) -> CGFloat)? { get set }
-
设置输入框和键盘的回弹触发最小距离,默认0始终回弹
Declaration
Swift
@MainActor public var reboundDistance: CGFloat { get set }
-
是否启用键盘后台关闭处理,退后台时收起键盘,回到前台时恢复键盘,解决系统退后台输入框跳动问题,默认NO
Declaration
Swift
@MainActor public var keyboardResign: Bool { get set }
-
是否启用点击背景关闭键盘(会继续触发其它点击事件),默认NO
Declaration
Swift
@MainActor public var touchResign: Bool { get set }
-
指定用于键盘管理滚动的scrollView,默认为nil,通过修改VC.view.frame实现
Declaration
Swift
@MainActor public weak var keyboardScrollView: UIScrollView? { get set }
-
点击键盘完成按钮是否关闭键盘,默认NO,二选一
Declaration
Swift
@MainActor public var returnResign: Bool { get set }
-
设置点击键盘完成按钮是否自动切换下一个输入框,二选一
Declaration
Swift
@MainActor public var returnNext: Bool { get set }
-
设置点击键盘完成按钮的事件句柄
Declaration
Swift
@MainActor public var returnBlock: ((UITextField) -> Void)? { get set }
-
获取关联的键盘Toolbar对象,可自定义样式
Declaration
Swift
@MainActor public var keyboardToolbar: UIToolbar { get set }
-
自定义键盘Toolbar上一个按钮,支持图片|字符串等(详见FWBlock),默认朝上的箭头
Declaration
Swift
@MainActor public var toolbarPreviousButton: Any? { get set }
-
自定义键盘Toolbar下一个按钮,支持图片|字符串等(详见FWBlock),默认朝下的箭头
Declaration
Swift
@MainActor public var toolbarNextButton: Any? { get set }
-
自定义键盘Toolbar完成按钮,支持图片|字符串等(详见FWBlock),默认Done
Declaration
Swift
@MainActor public var toolbarDoneButton: Any? { get set }
-
设置Toolbar点击前一个按钮时聚焦的输入框句柄,默认nil
Declaration
Swift
@MainActor public var previousResponder: ((UITextField) -> UIResponder?)? { get set }
-
设置Toolbar点击下一个按钮时聚焦的输入框句柄,默认nil
Declaration
Swift
@MainActor public var nextResponder: ((UITextField) -> UIResponder?)? { get set }
-
设置Toolbar点击前一个按钮时聚焦的输入框tag,默认0不生效
Declaration
Swift
@MainActor public var previousResponderTag: Int { get set }
-
设置Toolbar点击下一个按钮时聚焦的输入框tag,默认0不生效
Declaration
Swift
@MainActor public var nextResponderTag: Int { get set }
-
自动跳转前一个输入框,优先使用previousResponder,其次根据responderTag查找
Declaration
Swift
@MainActor public func goPrevious()
-
自动跳转后一个输入框,优先使用nextResponder,其次根据responderTag查找
Declaration
Swift
@MainActor public func goNext()
-
获取键盘弹出时的高度,对应Key为UIKeyboardFrameEndUserInfoKey
Declaration
Swift
@MainActor public func keyboardHeight(_ notification: Notification) -> CGFloat
-
执行键盘跟随动画,支持AutoLayout,可通过keyboardHeight:获取键盘高度
Declaration
Swift
@MainActor public func keyboardAnimate(_ notification: Notification, animations: @escaping @MainActor @Sendable () -> Void, completion: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
添加Toolbar,指定标题和完成句柄,使用默认按钮
Declaration
Swift
@MainActor public func addToolbar(title: Any? = nil, doneBlock: (@MainActor @Sendable (UIBarButtonItem) -> Void)? = nil)
Parameters
title
标题,不能点击
doneBlock
右侧完成按钮句柄,默认收起键盘
-
添加Toolbar,指定居中标题、左侧上一个、下一个按钮和右边按钮
Declaration
Swift
@MainActor public func addToolbar(titleItem: UIBarButtonItem?, previousItem: UIBarButtonItem?, nextItem: UIBarButtonItem?, doneItem: UIBarButtonItem?)
Parameters
titleItem
居中标题按钮
previousItem
左侧前一个按钮
nextItem
左侧下一个按钮
doneItem
右侧完成按钮
-
是否启用键盘管理(自动滚动),默认NO
Declaration
Swift
@MainActor public var keyboardManager: Bool { get set }
-
设置输入框和键盘的空白间距,默认10.0
Declaration
Swift
@MainActor public var keyboardDistance: CGFloat { get set }
-
设置输入框和键盘的空白间距句柄,参数为键盘高度、输入框高度,优先级高,默认nil
Declaration
Swift
@MainActor public var keyboardDistanceBlock: ((_ keyboardHeight: CGFloat, _ height: CGFloat) -> CGFloat)? { get set }
-
设置输入框和键盘的回弹触发最小距离,默认0始终回弹
Declaration
Swift
@MainActor public var reboundDistance: CGFloat { get set }
-
是否启用键盘后台关闭处理,退后台时收起键盘,回到前台时恢复键盘,解决系统退后台输入框跳动问题,默认NO
Declaration
Swift
@MainActor public var keyboardResign: Bool { get set }
-
是否启用点击背景关闭键盘(会继续触发其它点击事件),默认NO
Declaration
Swift
@MainActor public var touchResign: Bool { get set }
-
指定用于键盘管理滚动的scrollView,默认为nil,通过修改VC.view.frame实现
Declaration
Swift
@MainActor public weak var keyboardScrollView: UIScrollView? { get set }
-
点击键盘完成按钮是否关闭键盘,默认NO,二选一。此方法会修改delegate,可使用fwDelegate访问原始delegate
Declaration
Swift
@MainActor public var returnResign: Bool { get set }
-
设置点击键盘完成按钮是否自动切换下一个输入框,二选一。此方法会修改delegate,可使用fwDelegate访问原始delegate
Declaration
Swift
@MainActor public var returnNext: Bool { get set }
-
设置点击键盘完成按钮的事件句柄。此方法会修改delegate,可使用fwDelegate访问原始delegate
Declaration
Swift
@MainActor public var returnBlock: ((UITextView) -> Void)? { get set }
-
调用上面三个方法后会修改delegate,此方法始终访问外部delegate
Declaration
Swift
@MainActor public weak var delegate: UITextViewDelegate? { get set }
-
获取关联的键盘Toolbar对象,可自定义样式
Declaration
Swift
@MainActor public var keyboardToolbar: UIToolbar { get set }
-
自定义键盘Toolbar上一个按钮,支持图片|字符串等(详见FWBlock),默认朝上的箭头
Declaration
Swift
@MainActor public var toolbarPreviousButton: Any? { get set }
-
自定义键盘Toolbar下一个按钮,支持图片|字符串等(详见FWBlock),默认朝下的箭头
Declaration
Swift
@MainActor public var toolbarNextButton: Any? { get set }
-
自定义键盘Toolbar完成按钮,支持图片|字符串等(详见FWBlock),默认Done
Declaration
Swift
@MainActor public var toolbarDoneButton: Any? { get set }
-
设置Toolbar点击前一个按钮时聚焦的输入框句柄,默认nil
Declaration
Swift
@MainActor public var previousResponder: ((UITextView) -> UIResponder?)? { get set }
-
设置Toolbar点击下一个按钮时聚焦的输入框句柄,默认nil
Declaration
Swift
@MainActor public var nextResponder: ((UITextView) -> UIResponder?)? { get set }
-
设置Toolbar点击前一个按钮时聚焦的输入框tag,默认0不生效
Declaration
Swift
@MainActor public var previousResponderTag: Int { get set }
-
设置Toolbar点击下一个按钮时聚焦的输入框tag,默认0不生效
Declaration
Swift
@MainActor public var nextResponderTag: Int { get set }
-
自动跳转前一个输入框,优先使用previousResponder,其次根据responderTag查找
Declaration
Swift
@MainActor public func goPrevious()
-
自动跳转后一个输入框,优先使用nextResponder,其次根据responderTag查找
Declaration
Swift
@MainActor public func goNext()
-
获取键盘弹出时的高度,对应Key为UIKeyboardFrameEndUserInfoKey
Declaration
Swift
@MainActor public func keyboardHeight(_ notification: Notification) -> CGFloat
-
执行键盘跟随动画,支持AutoLayout,可通过keyboardHeight:获取键盘高度
Declaration
Swift
@MainActor public func keyboardAnimate(_ notification: Notification, animations: @escaping @MainActor @Sendable () -> Void, completion: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
添加Toolbar,指定标题和完成句柄,使用默认按钮
Declaration
Swift
@MainActor public func addToolbar(title: Any? = nil, doneBlock: (@MainActor @Sendable (UIBarButtonItem) -> Void)? = nil)
Parameters
title
标题,不能点击
doneBlock
右侧完成按钮句柄,默认收起键盘
-
添加Toolbar,指定居中标题、左侧上一个、下一个按钮和右边按钮
Declaration
Swift
@MainActor public func addToolbar(titleItem: UIBarButtonItem?, previousItem: UIBarButtonItem?, nextItem: UIBarButtonItem?, doneItem: UIBarButtonItem?)
Parameters
titleItem
居中标题按钮
previousItem
左侧前一个按钮
nextItem
左侧下一个按钮
doneItem
右侧完成按钮
-
占位文本,默认nil
Declaration
Swift
@MainActor public var placeholder: String? { get set }
-
占位颜色,默认系统颜色
Declaration
Swift
@MainActor public var placeholderColor: UIColor? { get set }
-
带属性占位文本,默认nil
Declaration
Swift
@MainActor public var attributedPlaceholder: NSAttributedString? { get set }
-
自定义占位文本内间距,默认zero与内容一致
Declaration
Swift
@MainActor public var placeholderInset: UIEdgeInsets { get set }
-
自定义垂直分布方式,会自动修改contentInset,默认Top与系统一致
Declaration
Swift
@MainActor public var verticalAlignment: UIControl.ContentVerticalAlignment { get set }
-
是否启用自动高度功能,随文字改变高度
Declaration
Swift
@MainActor public var autoHeightEnabled: Bool { get set }
-
最大高度,默认CGFLOAT_MAX,启用自动高度后生效
Declaration
Swift
@MainActor public var maxHeight: CGFloat { get set }
-
最小高度,默认0,启用自动高度后生效
Declaration
Swift
@MainActor public var minHeight: CGFloat { get set }
-
高度改变回调句柄,默认nil,启用自动高度后生效
Declaration
Swift
@MainActor public var heightDidChange: ((CGFloat) -> Void)? { get set }
-
快捷启用自动高度,并设置最大高度和回调句柄
Declaration
Swift
@MainActor public func autoHeight(maxHeight height: CGFloat, didChange: (@MainActor @Sendable (CGFloat) -> Void)?)
-
快速读取本地化语言
Declaration
Swift
public var localized: String { get }
-
快速读取本地化语言,指定Bundle
Declaration
Swift
public func localized(_ bundle: Bundle?) -> String
Parameters
bundle
语言所在Bundle,默认主Bundle
Return Value
本地化字符串
-
快速读取本地化语言,指定表名和Bundle
Declaration
Swift
public func localized(_ table: String?, _ bundle: Bundle? = nil) -> String
Parameters
table
本地化表名,默认Localizable.strings
bundle
语言所在Bundle,默认主Bundle
Return Value
本地化字符串
-
根据本地化语言加载当前bundle内语言文件,支持动态切换
Declaration
Swift
public func localizedBundle() -> Bundle
-
加载当前bundle内指定语言文件,加载失败返回nil
Declaration
Swift
public func localizedBundle(language: String?) -> Bundle?
-
是否启用本地化语言加载bundle,支持动态切换,默认false
Declaration
Swift
public var localizedBundleEnabled: Bool { get set }
-
读取应用可用语言列表
Declaration
Swift
public static var availableLanguages: [String] { get }
-
读取指定语言显示名称,可指定本地化标识(默认当前语言)
Declaration
Swift
public static func languageName(for language: String, localeIdentifier: String? = nil) -> String
-
读取应用当前语言,如果localizedLanguage存在则返回,否则返回systemLanguage
Declaration
Swift
public static var currentLanguage: String? { get }
-
读取当前系统语言,不满足需求时可自定义,兼容应用设置且不含区域,示例:zh-Hans
备注:
- Bundle.main.preferredLocalizations只包含语言信息,只返回App支持的语言,示例:zh-Hans;注意localizedLanguage重置为nil后需下次启动才能获取到当前系统语言
- Locale.preferredLanguages包含语言和区域信息,可能返回App不支持的语言,示例:zh-Hans-CN;注意localizedLanguage重置为nil后无需下次启动即可获取到当前系统语言
Declaration
Swift
public static var systemLanguage: String? { get set }
-
读取或设置自定义本地化语言,未自定义时为空。(语言值对应本地化文件存在才会立即生效,如zh-Hans|en),为空时清空自定义,会触发通知。默认只处理mainBundle语言,如果需要处理三方SDK和系统组件语言,详见Bundle分类
Declaration
Swift
public static var localizedLanguage: String? { get set }
-
读取本地化字符串,可指定table,strings文件需位于mainBundle,支持动态切换
Declaration
Swift
public static func localizedString(_ key: String, table: String? = nil) -> String
-
加载指定名称bundle对象,bundle文件需位于mainBundle
Declaration
Swift
public static func bundle(name: String) -> Bundle?
-
加载指定类所在bundle对象,可指定子目录名称,一般用于Framework内bundle文件
Declaration
Swift
public static func bundle(with clazz: AnyClass, name: String?) -> Bundle?
-
读取指定bundle内strings文件本地化字符串,支持动态切换
Declaration
Swift
public static func localizedString(_ key: String, bundle: Bundle?) -> String
-
读取指定bundle内strings文件本地化字符串,指定table,支持动态切换
Declaration
Swift
public static func localizedString(_ key: String, table: String?, bundle: Bundle?) -> String
-
读取当前bundle的可执行程序名称,一般和模块名称相同
Declaration
Swift
public var executableName: String { get }
-
创建CADisplayLink,使用target-action,自动CommonModes添加到当前的运行循环中,避免ScrollView滚动时不触发
Declaration
Swift
public static func commonDisplayLink(target: Any, selector: Selector) -> CADisplayLink
Parameters
target
目标
selector
方法
Return Value
CADisplayLink
-
创建CADisplayLink,使用block,自动CommonModes添加到当前的运行循环中,避免ScrollView滚动时不触发
Declaration
Swift
public static func commonDisplayLink(block: @escaping @Sendable (CADisplayLink) -> Void) -> CADisplayLink
Parameters
block
代码块
Return Value
CADisplayLink
-
创建CADisplayLink,使用block,需要调用addToRunLoop:forMode:安排到当前的运行循环中(CommonModes避免ScrollView滚动时不触发)。
示例:[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]
Declaration
Swift
public static func displayLink(block: @escaping @Sendable (CADisplayLink) -> Void) -> CADisplayLink
Parameters
block
代码块
Return Value
CADisplayLink
-
设置动画开始回调,需要在add之前添加,因为add时会自动拷贝一份对象
Declaration
Swift
public var startBlock: (@Sendable (CAAnimation) -> Void)? { get set }
-
设置动画停止回调
Declaration
Swift
public var stopBlock: (@Sendable (CAAnimation, Bool) -> Void)? { get set }
-
设置主题背景色,启用主题订阅后可跟随系统改变,清空时需置为nil
Declaration
Swift
public var themeBackgroundColor: UIColor? { get set }
-
设置主题边框色,启用主题订阅后可跟随系统改变,清空时需置为nil
Declaration
Swift
public var themeBorderColor: UIColor? { get set }
-
设置主题阴影色,启用主题订阅后可跟随系统改变,清空时需置为nil
Declaration
Swift
public var themeShadowColor: UIColor? { get set }
-
设置主题内容图片,启用主题订阅后可跟随系统改变,清空时需置为nil
Declaration
Swift
public var themeContents: UIImage? { get set }
-
设置阴影颜色、偏移和半径
Declaration
Swift
public func setShadowColor( _ color: UIColor?, offset: CGSize, radius: CGFloat )
-
移除所有支持动画属性的默认动画,需要一个不带动画的layer时使用
Declaration
Swift
public func removeDefaultAnimations()
-
生成图片截图,默认大小为frame.size
Declaration
Swift
public func snapshotImage(size: CGSize = .zero) -> UIImage?
-
设置主题渐变色,启用主题订阅后可跟随系统改变,清空时需置为nil
Declaration
Swift
public var themeColors: [UIColor]? { get set }
-
创建渐变层,需手工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
-
绘制形状路径,需要在drawRect中调用
@param bezierPath 绘制路径 @param strokeWidth 绘制宽度 @param strokeColor 绘制颜色 @param fillColor 填充颜色
Declaration
Swift
@MainActor public func drawBezierPath( _ bezierPath: UIBezierPath, strokeWidth: CGFloat, strokeColor: UIColor, fillColor: UIColor? )
-
绘制渐变颜色,需要在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
@MainActor 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
@MainActor 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 @MainActor public func addGradientLayer( _ frame: CGRect, colors: [Any], locations: [NSNumber]?, startPoint: CGPoint, endPoint: CGPoint ) -> CAGradientLayer
-
添加虚线Layer
@param rect 虚线区域,从中心绘制 @param lineLength 虚线的宽度 @param lineSpacing 虚线的间距 @param lineColor 虚线的颜色 @return 虚线Layer
Declaration
Swift
@discardableResult @MainActor public func addDashLayer( _ rect: CGRect, lineLength: CGFloat, lineSpacing: CGFloat, lineColor: UIColor ) -> CALayer
-
添加UIView动画,使用默认动画参数 @note 如果动画过程中需要获取进度,可通过添加CADisplayLink访问layer.presentationLayer获取,下同
@param block 动画代码块 @param duration 持续时间 @param options 动画选项,默认7<<16 @param completion 完成事件
Declaration
Swift
@MainActor public func addAnimation( block: @escaping @MainActor @Sendable () -> Void, duration: TimeInterval, options: UIView.AnimationOptions? = nil, completion: (@MainActor @Sendable (Bool) -> Void)? = nil )
-
添加UIView动画
@param curve 动画速度 @param transition 动画类型 @param duration 持续时间,默认0.2 @param animations 动画句柄 @param completion 完成事件
Declaration
Swift
@MainActor public func addAnimation( curve: UIView.AnimationOptions, transition: UIView.AnimationOptions, duration: TimeInterval, animations: (@MainActor @Sendable () -> Void)? = nil, completion: (@MainActor @Sendable (Bool) -> Void)? = nil )
-
添加CABasicAnimation动画
@param keyPath 动画路径 @param fromValue 开始值 @param toValue 结束值 @param duration 持续时间,0为默认(0.25秒) @param completion 完成事件 @return CABasicAnimation
Declaration
Swift
@discardableResult @MainActor public func addAnimation( keyPath: String, fromValue: Any, toValue: Any, duration: CFTimeInterval, completion: (@MainActor @Sendable (Bool) -> Void)? = nil ) -> CABasicAnimation
-
添加转场动画,可指定animationsEnabled,一般用于window切换rootViewController
@param options 动画选项 @param block 动画代码块 @param duration 持续时间 @param animationsEnabled 是否启用动画,默认true @param completion 完成事件
Declaration
Swift
@MainActor public func addTransition( options: UIView.AnimationOptions = [], block: @escaping @MainActor @Sendable () -> Void, duration: TimeInterval, animationsEnabled: Bool = true, completion: (@MainActor @Sendable (Bool) -> Void)? = nil )
-
添加CATransition转场动画 备注:移除动画可调用removeAnimation
@param type 动画类型 @param subtype 子类型 @param timingFunction 动画速度 @param duration 持续时间,0为默认(0.25秒) @param completion 完成事件 @return CATransition
Declaration
Swift
@discardableResult @MainActor public func addTransition( type: CATransitionType, subtype: CATransitionSubtype?, timingFunction: CAMediaTimingFunction?, duration: CFTimeInterval, completion: (@MainActor @Sendable (Bool) -> Void)? = nil ) -> CATransition
-
移除单个框架视图动画,key默认FWAnimation
Declaration
Swift
@MainActor public func removeAnimation(forKey key: String = "FWAnimation")
-
移除所有视图动画
Declaration
Swift
@MainActor public func removeAllAnimations()
-
绘制动画
@param layer CAShapeLayer层 @param duration 持续时间 @param completion 完成回调 @return CABasicAnimation
Declaration
Swift
@discardableResult @MainActor public func stroke( layer: CAShapeLayer, duration: TimeInterval, completion: (@MainActor @Sendable (Bool) -> Void)? = nil ) -> CABasicAnimation
-
水平摇摆动画
@param times 摇摆次数,默认10 @param delta 摇摆宽度,默认5 @param duration 单次时间,默认0.03 @param completion 完成回调
Declaration
Swift
@MainActor public func shake( times: Int, delta: CGFloat, duration: TimeInterval, completion: (@MainActor @Sendable (Bool) -> Void)? = nil )
-
渐显隐动画
@param alpha 透明度 @param duration 持续时长 @param completion 完成回调
Declaration
Swift
@MainActor public func fade( alpha: CGFloat, duration: TimeInterval, completion: (@MainActor @Sendable (Bool) -> Void)? = nil )
-
渐变代码块动画
@param block 动画代码块,比如调用imageView.setImage:方法 @param duration 持续时长,建议0.5 @param completion 完成回调
Declaration
Swift
@MainActor public func fade( block: @escaping @MainActor @Sendable () -> Void, duration: TimeInterval, completion: (@MainActor @Sendable (Bool) -> Void)? = nil )
-
旋转动画
@param degree 旋转度数,备注:逆时针需设置-179.99。使用CAAnimation无此问题 @param duration 持续时长 @param completion 完成回调
Declaration
Swift
@MainActor public func rotate( degree: CGFloat, duration: TimeInterval, completion: (@MainActor @Sendable (Bool) -> Void)? = nil )
-
缩放动画
@param scaleX X轴缩放率 @param scaleY Y轴缩放率 @param duration 持续时长 @param completion 完成回调
Declaration
Swift
@MainActor public func scale( scaleX: CGFloat, scaleY: CGFloat, duration: TimeInterval, completion: (@MainActor @Sendable (Bool) -> Void)? = nil )
-
移动动画
@param point 目标点 @param duration 持续时长 @param completion 完成回调
Declaration
Swift
@MainActor public func move( point: CGPoint, duration: TimeInterval, completion: (@MainActor @Sendable (Bool) -> Void)? = nil )
-
移动变化动画
@param frame 目标区域 @param duration 持续时长 @param completion 完成回调
Declaration
Swift
@MainActor public func move( frame: CGRect, duration: TimeInterval, completion: (@MainActor @Sendable (Bool) -> Void)? = nil )
-
取消动画效果执行block
@param block 动画代码块 @param completion 完成事件
Declaration
Swift
@MainActor public static func animateNone( block: @escaping @MainActor @Sendable () -> Void, completion: (@MainActor @Sendable () -> Void)? = nil )
-
执行block动画完成后执行指定回调
@param block 动画代码块 @param completion 完成事件
Declaration
Swift
@MainActor public static func animate( block: @MainActor () -> Void, completion: (@MainActor @Sendable () -> Void)? = nil )
-
是否启用拖动,默认NO
Declaration
Swift
@MainActor public var dragEnabled: Bool { get set }
-
拖动手势,延迟加载
Declaration
Swift
@MainActor public var dragGesture: UIPanGestureRecognizer { get }
-
设置拖动限制区域,默认CGRectZero,无限制
Declaration
Swift
@MainActor public var dragLimit: CGRect { get set }
-
设置拖动动作有效区域,默认frame
Declaration
Swift
@MainActor public var dragArea: CGRect { get set }
-
是否允许横向拖动(X),默认YES
Declaration
Swift
@MainActor public var dragHorizontal: Bool { get set }
-
是否允许纵向拖动(Y),默认YES
Declaration
Swift
@MainActor public var dragVertical: Bool { get set }
-
开始拖动回调
Declaration
Swift
@MainActor public var dragStartedBlock: ((UIView) -> Void)? { get set }
-
拖动移动回调
Declaration
Swift
@MainActor public var dragMovedBlock: ((UIView) -> Void)? { get set }
-
结束拖动回调
Declaration
Swift
@MainActor public var dragEndedBlock: ((UIView) -> Void)? { get set }
-
指定主题样式获取对应静态颜色,iOS13+可跟随系统改变
Declaration
Swift
public func color(forStyle style: ThemeStyle) -> UIColor
-
是否是主题颜色,仅支持判断使用fwTheme创建的颜色
Declaration
Swift
public var isThemeColor: Bool { get }
-
动态创建主题色,分别指定浅色和深色
Declaration
Swift
public static func themeLight(_ light: UIColor, dark: UIColor) -> UIColor
-
动态创建主题色,指定提供句柄
Declaration
Swift
public static func themeColor(_ provider: @escaping @Sendable (ThemeStyle) -> UIColor) -> UIColor
-
动态创建主题色,指定名称和bundle,兼容iOS11+系统方式(仅iOS13+支持动态颜色)和手工指定。失败时返回clear防止崩溃
Declaration
Swift
public static func themeNamed(_ name: String, bundle: Bundle? = nil) -> UIColor
-
手工单个注册主题色,未配置主题色或者需兼容iOS11以下时可使用本方式
Declaration
Swift
public static func setThemeColor(_ color: UIColor?, forName name: String)
-
手工批量注册主题色,未配置主题色或者需兼容iOS11以下时可使用本方式
Declaration
Swift
public static func setThemeColors(_ nameColors: [String : UIColor])
-
获取当前主题样式对应静态图片用于显示,iOS13+可跟随系统改变
Declaration
Swift
public var image: UIImage? { get }
-
指定主题样式获取对应静态图片用于显示,iOS13+可跟随系统改变
Declaration
Swift
public func image(forStyle style: ThemeStyle) -> UIImage?
-
是否是主题图片,仅支持判断使用fwTheme创建的图片
Declaration
Swift
public var isThemeImage: Bool { get }
-
快速生成当前图片对应的默认主题图片
Declaration
Swift
public var themeImage: UIImage { get }
-
指定主题颜色,快速生成当前图片对应的主题图片
Declaration
Swift
public func themeImage(color themeColor: UIColor) -> UIImage
-
创建主题模拟动态图像,分别指定浅色和深色,不支持动态切换,需重新赋值才会变化
Declaration
Swift
public static func themeLight(_ light: UIImage?, dark: UIImage?) -> UIImage
-
创建主题模拟动态图像,指定提供句柄,不支持动态切换,需重新赋值才会变化
Declaration
Swift
public static func themeImage(_ provider: @escaping @Sendable (ThemeStyle) -> UIImage?) -> UIImage
-
创建主题模拟动态图像,指定名称和bundle,兼容系统方式(仅iOS13+支持动态图像)和手工指定,支持动态切换,需配置any和dark
Declaration
Swift
public static func themeNamed(_ name: String, bundle: Bundle? = nil) -> UIImage
-
手工单个注册主题图像,未配置主题图像时可使用本方式
Declaration
Swift
public static func setThemeImage(_ image: UIImage?, forName name: String)
-
手工批量注册主题图像,未配置主题图像时可使用本方式
Declaration
Swift
public static func setThemeImages(_ nameImages: [String : UIImage])
-
默认主题图片颜色,未设置时为浅色=>黑色,深色=>白色
Declaration
Swift
public static var themeImageColor: UIColor { get }
-
默认主题图片颜色配置句柄,默认nil
Declaration
Swift
public static var themeImageColorConfiguration: (@Sendable () -> UIColor)? { get set }
-
获取当前主题样式对应静态图片用于显示,iOS13+可跟随系统改变
Declaration
Swift
public var image: UIImage? { get }
-
指定主题样式获取对应静态图片用于显示,iOS13+可跟随系统改变
Declaration
Swift
public func image(forStyle style: ThemeStyle) -> UIImage?
-
是否是主题图片资源,仅支持判断使用fwTheme创建的图片资源
Declaration
Swift
public var isThemeAsset: Bool { get }
-
创建主题动态图片资源,分别指定浅色和深色,系统方式,推荐使用
Declaration
Swift
public static func themeLight(_ light: UIImage?, dark: UIImage?) -> UIImageAsset
-
创建主题动态图片资源,指定提供句柄,内部使用ThemeObject实现
Declaration
Swift
public static func themeAsset(_ provider: @escaping @Sendable (ThemeStyle) -> UIImage?) -> UIImageAsset
-
订阅主题通知并指定主题上下文(如vc|view),非UITraitEnvironment等需指定后才能响应系统主题
Declaration
Swift
@MainActor public weak var themeContext: (NSObject & UITraitEnvironment)? { get set }
-
添加iOS13主题改变通知回调,返回订阅唯一标志,需订阅后才生效
Declaration
Swift
@discardableResult @MainActor public func addThemeListener(_ listener: @escaping @MainActor @Sendable (ThemeStyle) -> Void) -> String
-
iOS13根据订阅唯一标志移除主题通知回调
Declaration
Swift
@MainActor public func removeThemeListener(_ identifier: String)
-
iOS13移除所有主题通知回调,一般用于cell重用
Declaration
Swift
@MainActor public func removeAllThemeListeners()
-
设置主题图片,自动跟随系统改变,清空时需置为nil,二选一
Declaration
Swift
@MainActor public var themeImage: UIImage? { get set }
-
设置主题图片资源,自动跟随系统改变,清空时需置为nil,二选一
Declaration
Swift
@MainActor public var themeAsset: UIImageAsset? { get set }
-
读取应用名称
Declaration
Swift
public static var appName: String { get }
-
读取应用显示名称,未配置时读取名称
Declaration
Swift
public static var appDisplayName: String { get }
-
读取应用主版本号,可自定义,示例:1.0.0
Declaration
Swift
public static var appVersion: String { get set }
-
读取应用构建版本号,示例:1.0.0.1
Declaration
Swift
public static var appBuildVersion: String { get }
-
读取应用唯一标识
Declaration
Swift
public static var appIdentifier: String { get }
-
读取应用可执行程序名称
Declaration
Swift
public static var appExecutable: String { get }
-
读取应用信息字典
Declaration
Swift
public static func appInfo(_ key: String) -> Any?
-
读取应用启动URL
Declaration
Swift
public static func appLaunchURL(_ options: [UIApplication.LaunchOptionsKey : Any]?) -> URL?
-
能否打开URL(NSString|NSURL),需配置对应URL SCHEME到Info.plist才能返回YES
Declaration
Swift
@MainActor public static func canOpenURL(_ url: URLParameter?) -> Bool
-
打开URL,支持NSString|NSURL,完成时回调,即使未配置URL SCHEME,实际也能打开成功,只要调用时已打开过对应App
Declaration
Swift
@MainActor public static func openURL(_ url: URLParameter?, completionHandler: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
打开通用链接URL,支持NSString|NSURL,完成时回调。如果是iOS10+通用链接且安装了App,打开并回调YES,否则回调NO
Declaration
Swift
@MainActor public static func openUniversalLinks(_ url: URLParameter?, completionHandler: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
判断URL是否是系统链接(如AppStore|电话|设置等),支持NSString|NSURL
Declaration
Swift
public static func isSystemURL(_ url: URLParameter?) -> Bool
-
判断URL是否在指定Scheme链接数组中,不区分大小写
Declaration
Swift
public static func isSchemeURL(_ url: URLParameter?, schemes: [String]) -> Bool
-
判断URL是否HTTP链接,支持NSString|NSURL
Declaration
Swift
public static func isHttpURL(_ url: URLParameter?) -> Bool
-
判断URL是否是AppStore链接,支持NSString|NSURL
Declaration
Swift
public static func isAppStoreURL(_ url: URLParameter?) -> Bool
-
打开AppStore下载页
Declaration
Swift
@MainActor public static func openAppStore(_ appId: String, completionHandler: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
打开AppStore评价页
Declaration
Swift
@MainActor public static func openAppStoreReview(_ appId: String, completionHandler: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
打开应用内评价,有次数限制
Declaration
Swift
@MainActor public static func openAppReview()
-
打开系统应用设置页
Declaration
Swift
@MainActor public static func openAppSettings(_ completionHandler: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
打开系统应用通知设置页
Declaration
Swift
@MainActor public static func openAppNotificationSettings(_ completionHandler: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
打开系统邮件App
Declaration
Swift
@MainActor public static func openMailApp(_ email: String, completionHandler: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
打开系统短信App
Declaration
Swift
@MainActor public static func openMessageApp(_ phone: String, completionHandler: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
打开系统电话App
Declaration
Swift
@MainActor public static func openPhoneApp(_ phone: String, completionHandler: (@MainActor @Sendable (Bool) -> Void)? = nil)
-
打开系统分享
Declaration
Swift
@MainActor public static func openActivityItems( _ activityItems: [Any], excludedTypes: [UIActivity.ActivityType]? = nil, completionHandler: UIActivityViewController.CompletionWithItemsHandler? = nil, customBlock: (@MainActor (UIActivityViewController) -> Void)? = nil )
-
打开内部浏览器,支持NSString|NSURL,点击完成时回调
Declaration
Swift
@MainActor public static func openSafariController( _ url: URLParameter?, completionHandler: (@MainActor @Sendable () -> Void)? = nil, customBlock: (@MainActor (SFSafariViewController) -> Void)? = nil )
-
打开短信控制器,完成时回调
Declaration
Swift
@MainActor public static func openMessageController( _ controller: MFMessageComposeViewController, completionHandler: (@MainActor @Sendable (Bool) -> Void)? = nil )
-
打开邮件控制器,完成时回调
Declaration
Swift
@MainActor public static func openMailController( _ controller: MFMailComposeViewController, completionHandler: (@MainActor @Sendable (Bool) -> Void)? = nil )
-
打开Store控制器,完成时回调
Declaration
Swift
@MainActor public static func openStoreController( _ parameters: [String: Any], completionHandler: (@MainActor @Sendable (Bool) -> Void)? = nil, customBlock: (@MainActor @Sendable (SKStoreProductViewController) -> Void)? = nil )
-
打开视频播放器,支持AVPlayerItem|NSURL|NSString
Declaration
Swift
@MainActor public static func openVideoPlayer(_ url: Any?) -> AVPlayerViewController?
-
打开音频播放器,支持NSURL|NSString
Declaration
Swift
public static func openAudioPlayer(_ url: URLParameter?) -> AVAudioPlayer?
-
播放内置声音文件,完成后回调
Declaration
Swift
@discardableResult public static func playSystemSound(_ file: String, completionHandler: (@Sendable () -> Void)? = nil) -> SystemSoundID
-
停止播放内置声音文件
Declaration
Swift
public static func stopSystemSound(_ soundId: SystemSoundID)
-
播放内置震动,完成后回调
Declaration
Swift
public static func playSystemVibrate(_ completionHandler: (@Sendable () -> Void)? = nil)
-
播放触控反馈
Declaration
Swift
@MainActor public static func playImpactFeedback(_ style: UIImpactFeedbackGenerator.FeedbackStyle = .medium, intensity: CGFloat? = nil)
-
语音朗读文字,可指定语言(如zh-CN),默认系统
Declaration
Swift
@discardableResult public static func playSpeechUtterance(_ string: String, language: String? = nil) -> AVSpeechSynthesizer
-
是否是盗版(不是从AppStore安装)
Declaration
Swift
public static var isPirated: Bool { get }
-
是否是Testflight版本(非AppStore)
Declaration
Swift
public static var isTestflight: Bool { get }
-
是否是AppStore版本
Declaration
Swift
public static var isAppStore: Bool { get }
-
开始后台任务,task必须调用completionHandler
Declaration
Swift
@MainActor public static func beginBackgroundTask( _ task: (@escaping @Sendable () -> Void) -> Void, name: String? = nil, expirationHandler: (@MainActor @Sendable () -> Void)? = nil )
-
获取当前颜色指定透明度的新颜色
Declaration
Swift
public func color(alpha: CGFloat) -> UIColor
-
读取颜色的十六进制值RGB,不含透明度
Declaration
Swift
public var hexValue: Int { get }
-
读取颜色的透明度值,范围0~1
Declaration
Swift
public var alphaValue: CGFloat { get }
-
读取颜色的十六进制字符串RGB,不含透明度
Declaration
Swift
public var hexString: String { get }
-
读取颜色的十六进制字符串RGBA|ARGB(透明度为1时RGB),包含透明度
Declaration
Swift
public var hexAlphaString: String { get }
-
设置十六进制颜色标准为ARGB|RGBA,启用为ARGB,默认为RGBA
Declaration
Swift
public static var colorStandardARGB: Bool { get set }
-
获取透明度为1.0的RGB随机颜色
Declaration
Swift
public static var randomColor: UIColor { get }
-
从十六进制值初始化,格式:0x20B2AA,透明度默认1.0
Declaration
Swift
public static func color(hex: Int, alpha: CGFloat = 1.0) -> UIColor
-
从十六进制字符串初始化,支持RGB、RGBA|ARGB,格式:@“20B2AA”, @“#FFFFFF",透明度默认1.0,失败时返回clear
Declaration
Swift
public static func color(hexString: String, alpha: CGFloat = 1.0) -> UIColor
-
以指定模式添加混合颜色,默认normal模式
Declaration
Swift
public func addColor(_ color: UIColor, blendMode: CGBlendMode = .normal) -> UIColor
-
当前颜色修改亮度比率的颜色
Declaration
Swift
public func brightnessColor(_ ratio: CGFloat) -> UIColor
-
判断当前颜色是否为深色
Declaration
Swift
public var isDarkColor: Bool { get }
-
创建渐变颜色,支持四个方向,默认向下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
-
自定义全局自动等比例缩放适配句柄,默认nil,开启后如需固定大小调用fixed即可
Declaration
Swift
public static var autoScaleBlock: (@Sendable (CGFloat) -> CGFloat)? { get set }
-
快捷启用全局自动等比例缩放适配,自动设置默认autoScaleBlock
Declaration
Swift
public static var autoScaleFont: Bool { get set }
-
是否启用全局自动像素取整字体,默认false
Declaration
Swift
public static var autoFlatFont: Bool { get set }
-
全局自定义字体句柄,优先调用,返回nil时使用系统字体
Declaration
Swift
public static var fontBlock: (@Sendable (CGFloat, UIFont.Weight) -> UIFont?)? { get set }
-
返回系统Thin字体,自动等比例缩放
Declaration
Swift
public static func thinFont(ofSize: CGFloat, autoScale: Bool? = nil) -> UIFont
-
返回系统Light字体,自动等比例缩放
Declaration
Swift
public static func lightFont(ofSize: CGFloat, autoScale: Bool? = nil) -> UIFont
-
返回系统Medium字体,自动等比例缩放
Declaration
Swift
public static func mediumFont(ofSize: CGFloat, autoScale: Bool? = nil) -> UIFont
-
返回系统Semibold字体,自动等比例缩放
Declaration
Swift
public static func semiboldFont(ofSize: CGFloat, autoScale: Bool? = nil) -> UIFont
-
返回系统Bold字体,自动等比例缩放
Declaration
Swift
public static func boldFont(ofSize: CGFloat, autoScale: Bool? = nil) -> UIFont
-
创建指定尺寸和weight的系统字体,自动等比例缩放
Declaration
Swift
public static func font(ofSize size: CGFloat, weight: UIFont.Weight = .regular, autoScale: Bool? = nil) -> UIFont
-
创建指定尺寸和weight的不缩放系统字体
Declaration
Swift
public static func nonScaleFont(ofSize size: CGFloat, weight: UIFont.Weight = .regular) -> UIFont
-
获取指定名称、字重、斜体字体的完整规范名称
Declaration
Swift
public static func fontName(_ name: String, weight: UIFont.Weight, italic: Bool = false) -> String
-
是否是粗体
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 }
-
字体空白高度(上下之和)
Declaration
Swift
public var spaceHeight: CGFloat { get }
-
根据字体计算指定倍数行间距的实际行距值(减去空白高度),示例:行间距为0.5倍实际高度
Declaration
Swift
public func lineSpacing(multiplier: CGFloat) -> CGFloat
-
根据字体计算指定倍数行高的实际行高值(减去空白高度),示例:行高为1.5倍实际高度
Declaration
Swift
public func lineHeight(multiplier: CGFloat) -> CGFloat
-
计算指定期望高度下字体的实际行高值,取期望值和行高值的较大值
Declaration
Swift
public func lineHeight(expected: CGFloat) -> CGFloat
-
计算当前字体与指定字体居中对齐的偏移值
Declaration
Swift
public func baselineOffset(_ font: UIFont) -> CGFloat
-
计算当前字体与指定行高居中对齐的偏移值
Declaration
Swift
public func baselineOffset(lineHeight: CGFloat) -> CGFloat
-
从当前图片创建指定透明度的图片
Declaration
Swift
public func image(alpha: CGFloat) -> UIImage?
-
从当前UIImage混合颜色创建UIImage,可自定义模式,默认destinationIn
Declaration
Swift
public func image(tintColor: UIColor, blendMode: CGBlendMode = .destinationIn) -> UIImage?
-
等比例缩放图片长边到指定宽度
Declaration
Swift
public func image(scaleWidth width: CGFloat) -> UIImage?
-
缩放图片到指定大小
Declaration
Swift
public func image(scaleSize size: CGSize) -> UIImage?
-
缩放图片到指定大小,指定模式
Declaration
Swift
public func image(scaleSize size: CGSize, contentMode: UIView.ContentMode) -> UIImage?
-
按指定模式绘制图片
Declaration
Swift
public func draw(in rect: CGRect, contentMode: UIView.ContentMode, clipsToBounds: Bool)
-
裁剪指定区域图片
Declaration
Swift
public func image(cropRect: CGRect) -> UIImage?
-
指定颜色填充图片边缘
Declaration
Swift
public func image(insets: UIEdgeInsets, color: UIColor? = nil) -> UIImage?
-
拉伸图片(平铺模式),指定端盖区域(不拉伸区域)
Declaration
Swift
public func image(capInsets: UIEdgeInsets) -> UIImage
-
拉伸图片(指定模式),指定端盖区域(不拉伸区域)。Tile为平铺模式,Stretch为拉伸模式
Declaration
Swift
public func image(capInsets: UIEdgeInsets, resizingMode: UIImage.ResizingMode) -> UIImage
-
生成圆角图片
Declaration
Swift
public func image(cornerRadius: CGFloat) -> UIImage?
-
按角度常数(0~360)转动图片,指定图片尺寸是否延伸来适应内容,否则图片尺寸不变,内容被裁剪,默认true
Declaration
Swift
public func image(rotateDegree: CGFloat, fitSize: Bool = true) -> UIImage?
-
生成mark图片
Declaration
Swift
public func image(maskImage: UIImage) -> UIImage?
-
图片合并,并制定叠加图片的起始位置
Declaration
Swift
public func image(mergeImage: UIImage, atPoint: CGPoint) -> UIImage?
-
图片应用CIFilter滤镜处理
Declaration
Swift
public func image(filter: CIFilter) -> UIImage?
-
图片应用高斯模糊滤镜处理
Declaration
Swift
public func gaussianBlurImage(fuzzyValue: CGFloat = 10) -> UIImage?
-
图片应用像素化滤镜处理
Declaration
Swift
public func pixellateImage(fuzzyValue: CGFloat = 10) -> UIImage?
-
压缩图片到指定字节,图片太大时会改为JPG格式。不保证图片大小一定小于该大小
Declaration
Swift
public func compressImage(maxLength: Int, compressRatio: CGFloat = 0) -> UIImage?
-
压缩图片到指定字节,图片太大时会改为JPG格式,可设置递减压缩率,默认0.3。不保证图片大小一定小于该大小
Declaration
Swift
public func compressData(maxLength: Int, compressRatio: CGFloat = 0) -> Data?
-
长边压缩图片尺寸,获取等比例的图片
Declaration
Swift
public func compressImage(maxWidth: CGFloat) -> UIImage?
-
通过指定图片最长边,获取等比例的图片压缩size
Declaration
Swift
public func compressSize(maxWidth: CGFloat) -> CGSize
-
后台线程压缩图片,完成后主线程回调
Declaration
Swift
public static func compressImages( _ images: [UIImage], maxWidth: CGFloat, maxLength: Int, compressRatio: CGFloat = 0, completion: @escaping @MainActor @Sendable ([UIImage]) -> Void )
-
后台线程压缩图片数据,完成后主线程回调
Declaration
Swift
public static func compressDatas( _ images: [UIImage], maxWidth: CGFloat, maxLength: Int, compressRatio: CGFloat = 0, completion: @escaping @MainActor @Sendable ([Data]) -> Void )
-
获取原始渲染模式图片,始终显示原色,不显示tintColor。默认自动根据上下文
Declaration
Swift
public var originalImage: UIImage { get }
-
获取模板渲染模式图片,始终显示tintColor,不显示原色。默认自动根据上下文
Declaration
Swift
public var templateImage: UIImage { get }
-
判断图片是否有透明通道
Declaration
Swift
public var hasAlpha: Bool { get }
-
获取当前图片的像素大小,多倍图会放大到一倍
Declaration
Swift
public var pixelSize: CGSize { get }
-
从SF符号创建UIImage,可指定长边大小
Declaration
Swift
public static func image(systemName: String, scaleWidth: CGFloat? = nil) -> UIImage?
-
从视图创建UIImage,生成截图,主线程调用
Declaration
Swift
@MainActor public static func image(view: UIView) -> UIImage?
-
从颜色创建UIImage,尺寸默认1x1
Declaration
Swift
public static func image(color: UIColor?) -> UIImage?
-
从颜色创建UIImage,可指定尺寸和圆角,默认圆角0
Declaration
Swift
public static func image(color: UIColor?, size: CGSize, cornerRadius: CGFloat = 0) -> UIImage?
-
从block创建UIImage,指定尺寸
Declaration
Swift
public static func image(size: CGSize, block: (CGContext) -> Void) -> UIImage?
-
保存图片到相册,保存成功时error为nil
Declaration
Swift
public func saveImage(completion: (@Sendable (Error?) -> Void)? = nil)
-
保存视频到相册,保存成功时error为nil。如果视频地址为NSURL,需使用NSURL.path
Declaration
Swift
public static func saveVideo(_ videoPath: String, completion: (@Sendable (Error?) -> Void)? = nil)
-
获取灰度图
Declaration
Swift
public var grayImage: UIImage? { get }
-
获取图片的平均颜色
Declaration
Swift
public var averageColor: UIColor? { get }
-
倒影图片
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?
-
高斯模糊图片,默认模糊半径为10
Declaration
Swift
public func blurredImage(radius: CGFloat = 10) -> UIImage?
-
图片裁剪,可指定frame、角度、圆形等
Declaration
Swift
@MainActor public func croppedImage(frame: CGRect, angle: Int, circular: Bool) -> UIImage?
-
如果没有透明通道,增加透明通道
Declaration
Swift
public var alphaImage: UIImage { get }
-
截取View所有视图,包括旋转缩放效果
Declaration
Swift
@MainActor public static func image(view: UIView, limitWidth: CGFloat) -> UIImage?
-
获取AppIcon图片
Declaration
Swift
public static func appIconImage() -> UIImage?
-
获取AppIcon指定尺寸图片,名称格式:AppIcon60x60
Declaration
Swift
public static func appIconImage(size: CGSize) -> UIImage?
-
从Pdf数据或者路径创建指定大小UIImage
Declaration
Swift
public static func image(pdf path: Any, size: CGSize = .zero) -> UIImage?
-
创建渐变颜色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?
-
顶部纵坐标,frame.origin.y
Declaration
Swift
@MainActor public var top: CGFloat { get set }
-
底部纵坐标,frame.origin.y + frame.size.height
Declaration
Swift
@MainActor public var bottom: CGFloat { get set }
-
左边横坐标,frame.origin.x
Declaration
Swift
@MainActor public var left: CGFloat { get set }
-
右边横坐标,frame.origin.x + frame.size.width
Declaration
Swift
@MainActor public var right: CGFloat { get set }
-
宽度,frame.size.width
Declaration
Swift
@MainActor public var width: CGFloat { get set }
-
高度,frame.size.height
Declaration
Swift
@MainActor public var height: CGFloat { get set }
-
中心横坐标,center.x
Declaration
Swift
@MainActor public var centerX: CGFloat { get set }
-
中心纵坐标,center.y
Declaration
Swift
@MainActor public var centerY: CGFloat { get set }
-
起始横坐标,frame.origin.x
Declaration
Swift
@MainActor public var x: CGFloat { get set }
-
起始纵坐标,frame.origin.y
Declaration
Swift
@MainActor public var y: CGFloat { get set }
-
起始坐标,frame.origin
Declaration
Swift
@MainActor public var origin: CGPoint { get set }
-
大小,frame.size
Declaration
Swift
@MainActor public var size: CGSize { get set }
-
当前生命周期状态,需实现ViewControllerLifecycleObservable或手动添加监听后才有值,默认nil
Declaration
Swift
public nonisolated var lifecycleState: ViewControllerLifecycleState? { get set }
-
添加生命周期变化监听句柄(注意deinit不能访问runtime关联属性),返回监听者observer
Declaration
Swift
@discardableResult public nonisolated func observeLifecycleState(_ block: @escaping @MainActor @Sendable (Base, ViewControllerLifecycleState) -> Void) -> NSObjectProtocol
-
添加生命周期变化监听句柄,并携带自定义参数(注意deinit不能访问runtime关联属性),返回监听者observer
Declaration
Swift
@discardableResult public nonisolated func observeLifecycleState<T>(object: T, block: @escaping @MainActor @Sendable (Base, ViewControllerLifecycleState, T) -> Void) -> NSObjectProtocol where T : Sendable
-
移除生命周期监听者,传nil时移除所有
Declaration
Swift
@discardableResult public nonisolated func unobserveLifecycleState(observer: Any? = nil) -> Bool
-
自定义完成结果对象,默认nil
Declaration
Swift
public nonisolated var completionResult: Sendable? { get set }
-
自定义完成句柄,默认nil,dealloc时自动调用,参数为completionResult。支持提前调用,调用后需置为nil
Declaration
Swift
@MainActor public var completionHandler: ((Sendable?) -> Void)? { get set }
-
自定义侧滑返回手势VC开关句柄,enablePopProxy启用后生效,仅处理边缘返回手势,优先级低,默认nil
Declaration
Swift
@MainActor public var allowsPopGesture: (() -> Bool)? { get set }
-
自定义控制器返回VC开关句柄,enablePopProxy启用后生效,统一处理返回按钮点击和边缘返回手势,优先级高,默认nil
Declaration
Swift
@MainActor public var shouldPopController: (() -> Bool)? { get set }
-
单独启用返回代理拦截,优先级高于+enablePopProxy,启用后支持shouldPopController、allowsPopGesture功能,默认NO未启用
Declaration
Swift
@MainActor public func enablePopProxy()
-
全局启用返回代理拦截,优先级低于-enablePopProxy,启用后支持shouldPopController、allowsPopGesture功能,默认NO未启用
Declaration
Swift
@MainActor public static func enablePopProxy()
-
是否全局启用child状态栏样式代理,enablePopProxy时自动启用,默认false
Declaration
Swift
@MainActor public static var childProxyEnabled: Bool { get set }
-
openURL(_:
Asynchronous) 异步打开URL,支持NSString|NSURL,完成时回调,即使未配置URL SCHEME,实际也能打开成功,只要调用时已打开过对应App
Declaration
Swift
@MainActor public static func openURL(_ url: URLParameter?) async -> Bool
-
openUniversalLinks(_:
Asynchronous) 异步打开通用链接URL,支持NSString|NSURL,完成时回调。如果是iOS10+通用链接且安装了App,打开并回调YES,否则回调NO
Declaration
Swift
@MainActor public static func openUniversalLinks(_ url: URLParameter?) async -> Bool
-
openAppStore(_:
Asynchronous) 异步打开AppStore下载页
Declaration
Swift
@MainActor public static func openAppStore(_ appId: String) async -> Bool
-
openAppStoreReview(_:
Asynchronous) 异步打开AppStore评价页
Declaration
Swift
@MainActor public static func openAppStoreReview(_ appId: String) async -> Bool
-
openAppSettings()
Asynchronous异步打开系统应用设置页
Declaration
Swift
@MainActor public static func openAppSettings() async -> Bool
-
openAppNotificationSettings()
Asynchronous异步打开系统应用通知设置页
Declaration
Swift
@MainActor public static func openAppNotificationSettings() async -> Bool
-
openMailApp(_:
Asynchronous) 异步打开系统邮件App
Declaration
Swift
@MainActor public static func openMailApp(_ email: String) async -> Bool
-
openMessageApp(_:
Asynchronous) 异步打开系统短信App
Declaration
Swift
@MainActor public static func openMessageApp(_ phone: String) async -> Bool
-
openPhoneApp(_:
Asynchronous) 异步打开系统电话App
Declaration
Swift
@MainActor public static func openPhoneApp(_ phone: String) async -> Bool
-
绘制形状图片,自定义画笔宽度、画笔颜色、填充颜色,填充颜色为nil时不执行填充
Declaration
Swift
public func shapeImage( _ size: CGSize, strokeWidth: CGFloat, strokeColor: UIColor, fillColor: UIColor? ) -> UIImage?
-
绘制形状Layer,自定义画笔宽度、画笔颜色、填充颜色,填充颜色为nil时不执行填充
Declaration
Swift
public func shapeLayer( _ rect: CGRect, strokeWidth: CGFloat, strokeColor: UIColor, fillColor: UIColor? ) -> CAShapeLayer
-
根据点计算折线路径(NSValue点)
Declaration
Swift
public static func lines(points: [NSValue]) -> UIBezierPath
-
根据点计算贝塞尔曲线路径
Declaration
Swift
public static func quadCurvedPath(points: [NSValue]) -> UIBezierPath
-
计算两点的中心点
Declaration
Swift
public static func middlePoint(_ p1: CGPoint, with p2: CGPoint) -> CGPoint
-
计算两点的贝塞尔曲线控制点
Declaration
Swift
public static func controlPoint(_ p1: CGPoint, with p2: CGPoint) -> CGPoint
-
将角度(0~360)转换为弧度,周长为2*M_PI*r
Declaration
Swift
public static func radian(degree: CGFloat) -> CGFloat
-
将弧度转换为角度(0~360)
Declaration
Swift
public static func degree(radian: CGFloat) -> CGFloat
-
根据滑动方向计算rect的线段起点、终点中心点坐标数组(示范:田)。默认从上到下滑动
Declaration
Swift
public static func linePoints(rect: CGRect, direction: UISwipeGestureRecognizer.Direction) -> [NSValue]
-
设置设备token原始Data,格式化并保存
Declaration
Swift
public nonisolated static func setDeviceTokenData(_ tokenData: Data?)
-
获取设备Token格式化后的字符串
Declaration
Swift
public nonisolated static var deviceToken: String? { get set }
-
获取设备IDFV(内部使用),同账号应用全删除后会改变,可通过keychain持久化
Declaration
Swift
public nonisolated static var deviceIDFV: String? { get }
-
获取或设置设备UUID,自动keychain持久化。默认获取IDFV(未使用IDFA,避免额外权限),失败则随机生成一个
Declaration
Swift
public nonisolated static var deviceUUID: String { get set }
-
是否越狱
Declaration
Swift
public nonisolated static var isJailbroken: Bool { get }
-
本地IP地址
Declaration
Swift
public nonisolated static var ipAddress: String? { get }
-
本地主机名称
Declaration
Swift
public nonisolated static var hostName: String? { get }
-
手机蜂窝网络类型列表,仅区分2G|3G|4G|5G
Declaration
Swift
public nonisolated static var networkTypes: [String]? { get }
-
视图是否可见,视图hidden为NO、alpha>0.01、window存在且size不为0才认为可见
Declaration
Swift
@MainActor public var isViewVisible: Bool { get }
-
获取响应的视图控制器
Declaration
Swift
@MainActor public var viewController: UIViewController? { get }
-
设置额外热区(点击区域)
Declaration
Swift
@MainActor public var touchInsets: UIEdgeInsets { get set }
-
设置视图是否允许检测子视图pointInside,默认false
Declaration
Swift
@MainActor public var pointInsideSubviews: Bool { get set }
-
设置视图是否可穿透(子视图响应)
Declaration
Swift
@MainActor public var isPenetrable: Bool { get set }
-
设置自动计算适合高度的frame,需实现sizeThatFits:方法
Declaration
Swift
@MainActor public var fitFrame: CGRect { get set }
-
计算当前视图适合大小,需实现sizeThatFits:方法
Declaration
Swift
@MainActor public var fitSize: CGSize { get }
-
计算指定边界,当前视图适合大小,需实现sizeThatFits:方法
Declaration
Swift
@MainActor public func fitSize(drawSize: CGSize) -> CGSize
-
根据tag查找subview,仅从subviews中查找
Declaration
Swift
@MainActor public func subview(tag: Int) -> UIView?
-
根据accessibilityIdentifier查找subview,仅从subviews中查找
Declaration
Swift
@MainActor public func subview(identifier: String) -> UIView?
-
设置阴影颜色、偏移和半径
Declaration
Swift
@MainActor public func setShadowColor(_ color: UIColor?, offset: CGSize, radius: CGFloat)
-
绘制四边边框
Declaration
Swift
@MainActor public func setBorderColor(_ color: UIColor?, width: CGFloat)
-
绘制四边边框和四角圆角
Declaration
Swift
@MainActor public func setBorderColor(_ color: UIColor?, width: CGFloat, cornerRadius: CGFloat)
-
绘制四角圆角
Declaration
Swift
@MainActor public func setCornerRadius(_ radius: CGFloat)
-
绘制单边或多边边框Layer。frame必须存在(添加视图后可调用layoutIfNeeded更新frame)
Declaration
Swift
@MainActor public func setBorderLayer( _ edge: UIRectEdge, color: UIColor?, width: CGFloat )
-
绘制单边或多边边框Layer。frame必须存在(添加视图后可调用layoutIfNeeded更新frame)
Declaration
Swift
@MainActor public func setBorderLayer( _ edge: UIRectEdge, color: UIColor?, width: CGFloat, leftInset: CGFloat, rightInset: CGFloat )
-
绘制四边虚线边框和四角圆角。frame必须存在(添加视图后可调用layoutIfNeeded更新frame)
Declaration
Swift
@MainActor public func setDashBorderLayer( color: UIColor?, width: CGFloat, cornerRadius: CGFloat, lineLength: CGFloat, lineSpacing: CGFloat )
-
绘制单个或多个边框圆角,frame必须存在(添加视图后可调用layoutIfNeeded更新frame)
Declaration
Swift
@MainActor public func setCornerLayer( _ corner: UIRectCorner, radius: CGFloat )
-
绘制单个或多个边框圆角和四边边框,frame必须存在(添加视图后可调用layoutIfNeeded更新frame)
Declaration
Swift
@MainActor public func setCornerLayer( _ corner: UIRectCorner, radius: CGFloat, borderColor: UIColor?, width: CGFloat )
-
绘制单边或多边边框视图。使用AutoLayout
Declaration
Swift
@MainActor public func setBorderView( _ edge: UIRectEdge, color: UIColor?, width: CGFloat )
-
绘制单边或多边边框。使用AutoLayout
Declaration
Swift
@MainActor public func setBorderView( _ edge: UIRectEdge, color: UIColor?, width: CGFloat, leftInset: CGFloat, rightInset: CGFloat )
-
开始倒计时,从window移除时自动取消,回调参数为剩余时间
Declaration
Swift
@discardableResult @MainActor public func startCountDown( _ seconds: Int, block: @escaping @MainActor @Sendable (Int) -> Void ) -> DispatchSourceTimer
-
设置毛玻璃效果,使用UIVisualEffectView。内容需要添加到UIVisualEffectView.contentView
Declaration
Swift
@discardableResult @MainActor public func setBlurEffect(_ style: UIBlurEffect.Style) -> UIVisualEffectView?
-
移除所有子视图
Declaration
Swift
@MainActor public func removeAllSubviews()
-
递归查找指定子类的第一个子视图(含自身)
Declaration
Swift
@MainActor public func recursiveSubview<T>(of type: T.Type) -> T? where T : UIView
-
递归查找指定条件的第一个子视图(含自身)
Declaration
Swift
@MainActor public func recursiveSubview(block: (UIView) -> Bool) -> UIView?
-
递归查找指定父类的第一个父视图(含自身)
Declaration
Swift
@MainActor public func recursiveSuperview<T>(of type: T.Type) -> T? where T : UIView
-
递归查找指定条件的第一个父视图(含自身)
Declaration
Swift
@MainActor public func recursiveSuperview(block: (UIView) -> Bool) -> UIView?
-
图片截图
Declaration
Swift
@MainActor public var snapshotImage: UIImage? { get }
-
Pdf截图
Declaration
Swift
@MainActor public var snapshotPdf: Data? { get }
-
将要设置的frame按照view的anchorPoint(.5, .5)处理后再设置,而系统默认按照(0, 0)方式计算
Declaration
Swift
@MainActor public var frameApplyTransform: CGRect { get set }
-
自定义视图排序索引,需结合sortSubviews使用,默认0不处理
Declaration
Swift
@MainActor public var sortIndex: Int { get set }
-
根据sortIndex排序subviews,需结合sortIndex使用
Declaration
Swift
@MainActor public func sortSubviews()
-
是否显示灰色视图,仅支持iOS13+
Declaration
Swift
@MainActor public var hasGrayView: Bool { get }
-
显示灰色视图,仅支持iOS13+
Declaration
Swift
@MainActor public func showGrayView()
-
隐藏灰色视图,仅支持iOS13+
Declaration
Swift
@MainActor public func hideGrayView()
-
定义类通用样式实现句柄
Declaration
Swift
@MainActor public static func defineStyle( _ style: ViewStyle<Base>, block: @escaping @MainActor @Sendable (Base) -> Void )
-
应用类通用样式
Declaration
Swift
@MainActor public func addStyle(_ style: ViewStyle<Base>)
-
设置图片模式为scaleAspectFill,短边拉伸不变形,超过区域隐藏,一般用于宽度和高度都固定的场景
Declaration
Swift
@MainActor public func scaleAspectFill()
-
设置图片模式为scaleAspectFit,长边拉伸不变形,超过区域隐藏,一般用于仅宽度或高度固定的场景
Declaration
Swift
@MainActor public func scaleAspectFit()
-
优化图片人脸显示,参考:https://github.com/croath/UIImageView-BetterFace
Declaration
Swift
@MainActor public func faceAware()
-
倒影效果
Declaration
Swift
@MainActor public func reflect()
-
图片水印
Declaration
Swift
@MainActor public func setImage(_ image: UIImage, watermarkImage: UIImage, in rect: CGRect)
-
文字水印,指定区域
Declaration
Swift
@MainActor public func setImage(_ image: UIImage, watermarkString: NSAttributedString, in rect: CGRect)
-
文字水印,指定坐标
Declaration
Swift
@MainActor public func setImage(_ image: UIImage, watermarkString: NSAttributedString, at point: CGPoint)
-
获取指定索引TabBar根视图控制器(非导航控制器),找不到返回nil
Declaration
Swift
@MainActor public func getTabBarController(index: Int) -> UIViewController?
-
获取指定类TabBar根视图控制器(非导航控制器),找不到返回nil
Declaration
Swift
@MainActor public func getTabBarController<T>(of type: T.Type) -> T? where T : UIViewController
-
获取指定条件TabBar根视图控制器(非导航控制器),找不到返回nil
Declaration
Swift
@MainActor public func getTabBarController(block: (UIViewController) -> Bool) -> UIViewController?
-
选中并获取指定索引TabBar根视图控制器(非导航控制器),找不到返回nil
Declaration
Swift
@discardableResult @MainActor public func selectTabBarController(index: Int) -> UIViewController?
-
选中并获取指定类TabBar根视图控制器(非导航控制器),找不到返回nil
Declaration
Swift
@discardableResult @MainActor public func selectTabBarController<T>(of type: T.Type) -> T? where T : UIViewController
-
选中并获取指定条件TabBar根视图控制器(非导航控制器),找不到返回nil
Declaration
Swift
@discardableResult @MainActor public func selectTabBarController(block: (UIViewController) -> Bool) -> UIViewController?
-
快速设置attributedText样式,设置后调用setText:会自动转发到setAttributedText:方法
Declaration
Swift
@MainActor public var textAttributes: [NSAttributedString.Key : Any]? { get set }
-
快速设置文字的行高,优先级低于fwTextAttributes,设置后调用setText:会自动转发到setAttributedText:方法。小于等于0时恢复默认行高
Declaration
Swift
@MainActor public var lineHeight: CGFloat { get set }
-
自定义内容边距,未设置时为系统默认。当内容为空时不参与intrinsicContentSize和sizeThatFits:计算,方便自动布局
Declaration
Swift
@MainActor public var contentInset: UIEdgeInsets { get set }
-
纵向分布方式,默认居中
Declaration
Swift
@MainActor public var verticalAlignment: UIControl.ContentVerticalAlignment { get set }
-
添加点击手势并自动识别NSLinkAttributeName|URL属性,点击高亮时回调链接,点击其它区域回调nil
Declaration
Swift
@discardableResult @MainActor public func addLinkGesture(block: @escaping @MainActor @Sendable (Any?) -> Void) -> UITapGestureRecognizer
-
获取手势触发位置的文本属性,可实现行内点击效果等,allowsSpacing默认为NO空白处不可点击
Declaration
Swift
@MainActor public func attributes( gesture: UIGestureRecognizer, allowsSpacing: Bool ) -> [NSAttributedString.Key: Any]
-
快速设置字体并指定行高
Declaration
Swift
@MainActor public func setFont( _ font: UIFont?, lineHeight aLineHeight: CGFloat )
-
快速设置标签并指定文本
Declaration
Swift
@MainActor public func setFont( _ font: UIFont?, textColor: UIColor?, text: String? = nil, textAlignment: NSTextAlignment? = nil, numberOfLines: Int? = nil, lineHeight aLineHeight: CGFloat? = nil )
-
快速创建标签并指定文本
Declaration
Swift
@MainActor public static func label( font: UIFont?, textColor: UIColor?, text: String? = nil, textAlignment: NSTextAlignment? = nil, numberOfLines: Int? = nil, lineHeight: CGFloat? = nil ) -> Base
-
自适应字体大小,可设置缩放因子等
Declaration
Swift
@MainActor public func adjustsFontSize( minimumScaleFactor: CGFloat? = nil, baselineAdjustment: UIBaselineAdjustment? = nil )
-
获取当前标签是否非空,兼容attributedText|text
Declaration
Swift
@MainActor public var isNotEmpty: Bool { get }
-
计算当前标签实际显示行数,兼容contentInset|lineHeight
Declaration
Swift
@MainActor public var actualNumberOfLines: Int { get }
-
计算指定边界、内边距、行高、行数时,当前标签实际显示行数
Declaration
Swift
@MainActor public func actualNumberOfLines( drawSize: CGSize, contentInset aContentInset: UIEdgeInsets? = nil, lineHeight aLineHeight: CGFloat? = nil, numberOfLines aNumberOfLines: Int? = nil ) -> Int
-
计算当前文本所占尺寸,需frame或者宽度布局完整
Declaration
Swift
@MainActor public var textSize: CGSize { get }
-
计算指定边界时,当前文本所占尺寸
Declaration
Swift
@MainActor public func textSize( drawSize: CGSize, contentInset aContentInset: UIEdgeInsets? = nil ) -> CGSize
-
计算当前属性文本所占尺寸,需frame或者宽度布局完整,attributedText需指定字体
Declaration
Swift
@MainActor public var attributedTextSize: CGSize { get }
-
计算指定边界时,当前属性文本所占尺寸,attributedText需指定字体
Declaration
Swift
@MainActor public func attributedTextSize( drawSize: CGSize, contentInset aContentInset: UIEdgeInsets? = nil ) -> CGSize
-
Undocumented
Declaration
Swift
@MainActor public var touchEventInterval: TimeInterval { get set }
-
全局自定义按钮高亮时的alpha配置,默认0.5
Declaration
Swift
public nonisolated static var highlightedAlpha: CGFloat { get set }
-
全局自定义按钮禁用时的alpha配置,默认0.3
Declaration
Swift
public nonisolated static var disabledAlpha: CGFloat { get set }
-
自定义按钮禁用时的alpha,如0.3,默认0不生效
Declaration
Swift
@MainActor public var disabledAlpha: CGFloat { get set }
-
自定义按钮高亮时的alpha,如0.5,默认0不生效
Declaration
Swift
@MainActor public var highlightedAlpha: CGFloat { get set }
-
自定义按钮禁用状态改变时的句柄,默认nil
Declaration
Swift
@MainActor public var disabledChanged: ((UIButton, Bool) -> Void)? { get set }
-
快速切换按钮是否可用
Declaration
Swift
@MainActor public func toggleEnabled(_ enabled: Bool? = nil)
-
自定义按钮高亮状态改变时的句柄,默认nil
Declaration
Swift
@MainActor public var highlightedChanged: ((UIButton, Bool) -> Void)? { get set }
-
获取当前按钮是否非空,兼容attributedTitle|title|image
Declaration
Swift
@MainActor public var isNotEmpty: Bool { get }
-
是否内容为空时收缩且不占用布局尺寸,兼容attributedTitle|title|image
Declaration
Swift
@MainActor public var contentCollapse: Bool { get set }
-
快速设置文本按钮
Declaration
Swift
@MainActor public func setTitle(_ title: String?, font: UIFont?, titleColor: UIColor?)
-
快速设置文本
Declaration
Swift
@MainActor public func setTitle(_ title: String?)
-
快速设置图片
Declaration
Swift
@MainActor public func setImage(_ image: UIImage?)
-
设置图片的居中边位置,需要在setImage和setTitle之后调用才生效,且button大小大于图片+文字+间距
imageEdgeInsets: 仅有image时相对于button,都有时上左下相对于button,右相对于title,sizeThatFits不包含 titleEdgeInsets: 仅有title时相对于button,都有时上右下相对于button,左相对于image,sizeThatFits不包含 contentEdgeInsets: 内容边距,setImageEdge时不影响,sizeThatFits包含
Declaration
Swift
@MainActor public func setImageEdge(_ edge: UIRectEdge, spacing: CGFloat)
-
图文模式时自适应粗体文本,解决图文按钮文本显示不全(…)的兼容性问题
Declaration
Swift
@MainActor public func adjustBoldText()
-
设置状态背景色
Declaration
Swift
@MainActor public func setBackgroundColor(_ backgroundColor: UIColor?, for state: UIControl.State)
-
快速创建文本按钮
Declaration
Swift
@MainActor public static func button(title: String?, font: UIFont?, titleColor: UIColor?) -> Base
-
快速创建图片按钮
Declaration
Swift
@MainActor public static func button(image: UIImage?) -> Base
-
设置按钮倒计时,从window移除时自动取消。等待时按钮disabled,非等待时enabled。时间支持格式化,示例:重新获取(%lds)
Declaration
Swift
@discardableResult @MainActor public func startCountDown(_ seconds: Int, title: String, waitTitle: String) -> DispatchSourceTimer
-
判断当前scrollView内容是否足够滚动
Declaration
Swift
@MainActor public var canScroll: Bool { get }
-
判断当前的scrollView内容是否足够水平滚动
Declaration
Swift
@MainActor public var canScrollHorizontal: Bool { get }
-
判断当前的scrollView内容是否足够纵向滚动
Declaration
Swift
@MainActor public var canScrollVertical: Bool { get }
-
当前scrollView滚动到指定边
Declaration
Swift
@MainActor public func scroll(to edge: UIRectEdge, animated: Bool = true)
-
是否已滚动到指定边
Declaration
Swift
@MainActor public func isScroll(to edge: UIRectEdge) -> Bool
-
获取当前的scrollView滚动到指定边时的contentOffset(包含contentInset)
Declaration
Swift
@MainActor public func contentOffset(of edge: UIRectEdge) -> CGPoint
-
总页数,自动识别翻页方向
Declaration
Swift
@MainActor public var totalPage: Int { get }
-
当前页数,不支持动画,自动识别翻页方向
Declaration
Swift
@MainActor public var currentPage: Int { get set }
-
设置当前页数,支持动画,自动识别翻页方向
Declaration
Swift
@MainActor public func setCurrentPage(_ page: Int, animated: Bool = true)
-
是否是最后一页,自动识别翻页方向
Declaration
Swift
@MainActor public var isLastPage: Bool { get }
-
快捷设置contentOffset.x
Declaration
Swift
@MainActor public var contentOffsetX: CGFloat { get set }
-
快捷设置contentOffset.y
Declaration
Swift
@MainActor public var contentOffsetY: CGFloat { get set }
-
滚动视图完整图片截图
Declaration
Swift
@MainActor public var contentSnapshot: UIImage? { get }
-
内容视图,子视图需添加到本视图,布局约束完整时可自动滚动
当启用等比例缩放布局、且scrollView和contentView都固定高度时, 为防止浮点数误差导致scrollView拖拽时出现纵向可滚动的兼容问题,解决方案如下:
- 设置scrollView属性isDirectionalLockEnabled为true
- 设置布局高度为固定ceil高度,如:FW.fixed(ceil(FW.relative(40)))
Declaration
Swift
@MainActor public var contentView: UIView { get }
-
设置自动布局视图悬停到指定父视图固定位置,在scrollViewDidScroll:中调用即可
@param view 需要悬停的视图,须占满fromSuperview @param fromSuperview 起始的父视图,须是scrollView的子视图 @param toSuperview 悬停的目标视图,须是scrollView的父级视图,一般控制器view @param toPosition 需要悬停的目标位置,相对于toSuperview的originY位置 @return 相对于悬浮位置的距离,可用来设置导航栏透明度等
Declaration
Swift
@discardableResult @MainActor public func hoverView( _ view: UIView, fromSuperview: UIView, toSuperview: UIView, toPosition: CGFloat ) -> CGFloat
-
设置开始拖动时折叠视图动画,在scrollViewWillBeginDragging中调用即可
Declaration
Swift
@MainActor public func beginFoldingView( _ view: UIView, duration: TimeInterval = 0.25, animations: @escaping @MainActor @Sendable (UIView) -> Void )
Parameters
view
折叠视图
duration
动画时间,默认0.25秒
animations
动画句柄,AutoLayout动画需调用:view.superview?.layoutIfNeeded()
-
设置结束拖动时展开视图动画,在scrollViewDidEndDragging、scrollViewDidEndDecelerating中调用即可
Declaration
Swift
@MainActor public func endFoldingView( _ view: UIView, willDecelerate decelerate: Bool? = nil, afterDelay delay: TimeInterval = 1.0, duration: TimeInterval = 0.25, animations: @escaping @MainActor @Sendable (UIView) -> Void )
Parameters
view
展示视图
decelerate
是否将要减速,scrollViewDidEndDragging中传decelerate,scrollViewDidEndDecelerating不传
delay
延迟展开时间,默认1.0秒
duration
动画时间,默认0.25秒
animations
动画句柄,AutoLayout动画需调用:view.superview?.layoutIfNeeded()
-
是否开始识别pan手势
Declaration
Swift
@MainActor public var shouldBegin: ((UIGestureRecognizer) -> Bool)? { get set }
-
是否允许同时识别多个手势
Declaration
Swift
@MainActor public var shouldRecognizeSimultaneously: ((UIGestureRecognizer, UIGestureRecognizer) -> Bool)? { get set }
-
是否另一个手势识别失败后,才能识别pan手势
Declaration
Swift
@MainActor public var shouldRequireFailure: ((UIGestureRecognizer, UIGestureRecognizer) -> Bool)? { get set }
-
是否pan手势识别失败后,才能识别另一个手势
Declaration
Swift
@MainActor public var shouldBeRequiredToFail: ((UIGestureRecognizer, UIGestureRecognizer) -> Bool)? { get set }
-
获取手势直接作用的view,不同于view,此处是view的subview
Declaration
Swift
@MainActor public weak var targetView: UIView? { get }
-
是否正在拖动中:Began || Changed
Declaration
Swift
@MainActor public var isTracking: Bool { get }
-
是否是激活状态: isEnabled && (Began || Changed)
Declaration
Swift
@MainActor public var isActive: Bool { get }
-
判断手势是否正作用于指定视图
Declaration
Swift
@MainActor public func hitTest(view: UIView?) -> Bool
-
当前滑动方向,如果多个方向滑动,取绝对值较大的一方,失败返回0
Declaration
Swift
@MainActor public var swipeDirection: UISwipeGestureRecognizer.Direction { get }
-
当前滑动进度,滑动绝对值相对于手势视图的宽或高
Declaration
Swift
@MainActor public var swipePercent: CGFloat { get }
-
计算指定方向的滑动进度
Declaration
Swift
@MainActor public func swipePercent(of direction: UISwipeGestureRecognizer.Direction) -> CGFloat
-
自定义圆点大小,默认{10, 10}
Declaration
Swift
@MainActor public var preferredSize: CGSize { get set }
-
中间圆球的大小,默认zero
Declaration
Swift
@MainActor public var thumbSize: CGSize { get set }
-
中间圆球的颜色,默认nil
Declaration
Swift
@MainActor public var thumbColor: UIColor? { get set }
-
自定义尺寸大小,默认{51,31}
Declaration
Swift
@MainActor public var preferredSize: CGSize { get set }
-
自定义关闭时除圆点外的背景色
Declaration
Swift
@MainActor public var offTintColor: UIColor? { get set }
-
最大字数限制,0为无限制,二选一
Declaration
Swift
@MainActor public var maxLength: Int { get set }
-
最大Unicode字数限制(中文为1,英文为0.5),0为无限制,二选一
Declaration
Swift
@MainActor public var maxUnicodeLength: Int { get set }
-
自定义文字改变处理句柄,自动trimString,默认nil
Declaration
Swift
@MainActor public var textChangedBlock: ((String) -> Void)? { get set }
-
文本长度发生改变,自动检测字数限制,用于代码设置text等场景
Declaration
Swift
@MainActor public func textLengthChanged()
-
获取满足最大字数限制的过滤后的文本,无需再调用textLengthChanged
Declaration
Swift
@MainActor public func filterText(_ text: String) -> String
-
设置自动完成时间间隔,默认0.5秒,和autoCompleteBlock配套使用
Declaration
Swift
@MainActor public var autoCompleteInterval: TimeInterval { get set }
-
设置自动完成处理句柄,自动trimString,默认nil,注意输入框内容为空时会立即触发
Declaration
Swift
@MainActor public var autoCompleteBlock: ((String) -> Void)? { get set }
-
是否禁用长按菜单(拷贝、选择、粘贴等),默认NO
Declaration
Swift
@MainActor public var menuDisabled: Bool { get set }
-
自定义光标偏移和大小,不为0才会生效,默认zero不生效
Declaration
Swift
@MainActor public var cursorRect: CGRect { get set }
-
获取及设置当前选中文字范围
Declaration
Swift
@MainActor public var selectedRange: NSRange { get set }
-
移动光标到最后
Declaration
Swift
@MainActor public func selectAllRange()
-
移动光标到指定位置,兼容动态text赋值
Declaration
Swift
@MainActor public func moveCursor(_ offset: Int)
-
最大字数限制,0为无限制,二选一
Declaration
Swift
@MainActor public var maxLength: Int { get set }
-
最大Unicode字数限制(中文为1,英文为0.5),0为无限制,二选一
Declaration
Swift
@MainActor public var maxUnicodeLength: Int { get set }
-
自定义文字改变处理句柄,自动trimString,默认nil
Declaration
Swift
@MainActor public var textChangedBlock: ((String) -> Void)? { get set }
-
文本长度发生改变,自动检测字数限制,用于代码设置text等场景
Declaration
Swift
@MainActor public func textLengthChanged()
-
获取满足最大字数限制的过滤后的文本,无需再调用textLengthChanged
Declaration
Swift
@MainActor public func filterText(_ text: String) -> String
-
设置自动完成时间间隔,默认0.5秒,和autoCompleteBlock配套使用
Declaration
Swift
@MainActor public var autoCompleteInterval: TimeInterval { get set }
-
设置自动完成处理句柄,默认nil,注意输入框内容为空时会立即触发
Declaration
Swift
@MainActor public var autoCompleteBlock: ((String) -> Void)? { get set }
-
是否禁用长按菜单(拷贝、选择、粘贴等),默认NO
Declaration
Swift
@MainActor public var menuDisabled: Bool { get set }
-
自定义光标偏移和大小,不为0才会生效,默认zero不生效
Declaration
Swift
@MainActor public var cursorRect: CGRect { get set }
-
获取及设置当前选中文字范围
Declaration
Swift
@MainActor public var selectedRange: NSRange { get set }
-
移动光标到最后
Declaration
Swift
@MainActor public func selectAllRange()
-
移动光标到指定位置,兼容动态text赋值
Declaration
Swift
@MainActor public func moveCursor(_ offset: Int)
-
计算当前文本所占尺寸,包含textContainerInset,需frame或者宽度布局完整
Declaration
Swift
@MainActor public var textSize: CGSize { get }
-
计算指定边界时,当前文本所占尺寸,包含textContainerInset
Declaration
Swift
@MainActor public func textSize(drawSize: CGSize, contentInset: UIEdgeInsets? = nil) -> CGSize
-
计算当前属性文本所占尺寸,包含textContainerInset,需frame或者宽度布局完整,attributedText需指定字体
Declaration
Swift
@MainActor public var attributedTextSize: CGSize { get }
-
计算指定边界时,当前属性文本所占尺寸,包含textContainerInset,attributedText需指定字体
Declaration
Swift
@MainActor public func attributedTextSize(drawSize: CGSize, contentInset: UIEdgeInsets? = nil) -> CGSize
-
重置输入框默认间距样式,可指定是否只读(禁用编辑、选择、滚动,类似UILabel)
Declaration
Swift
@MainActor public func resetTextStyle(readOnly: Bool? = nil)
-
获取手势触发位置的文本属性,可实现行内点击效果等,allowsSpacing默认为NO空白处不可点击
Declaration
Swift
@MainActor public func attributes( gesture: UIGestureRecognizer, allowsSpacing: Bool ) -> [NSAttributedString.Key: Any]
-
快捷设置行高,兼容placeholder和typingAttributes。小于等于0时恢复默认行高
Declaration
Swift
@MainActor public var lineHeight: CGFloat { get set }
-
获取当前文本框是否非空,兼容attributedText|text
Declaration
Swift
@MainActor public var isNotEmpty: Bool { get }
-
计算当前文本框实际显示行数,兼容textContainerInset|lineHeight
Declaration
Swift
@MainActor public var actualNumberOfLines: Int { get }
-
计算指定边界、内边距、行高时,当前文本框实际显示行数
Declaration
Swift
@MainActor public func actualNumberOfLines( drawSize: CGSize, contentInset: UIEdgeInsets? = nil, lineHeight aLineHeight: CGFloat? = nil ) -> Int
-
全局清空TableView默认多余边距
Declaration
Swift
@MainActor public static func resetTableStyle()
-
是否启动高度估算布局,启用后需要子视图布局完整,无需实现heightForRow方法(iOS11默认启用,会先cellForRow再heightForRow)
Declaration
Swift
@MainActor public var estimatedLayout: Bool { get set }
-
清除Grouped等样式默认多余边距,注意CGFLOAT_MIN才会生效,0不会生效
Declaration
Swift
@MainActor public func resetTableStyle()
-
配置全局resetTableStyle钩子句柄,默认nil
Declaration
Swift
@MainActor public static var resetTableConfiguration: ((UITableView) -> Void)? { get set }
-
reloadData完成回调
Declaration
Swift
@MainActor public func reloadData(completion: (@MainActor @Sendable () -> Void)?)
-
reloadData禁用动画
Declaration
Swift
@MainActor public func reloadDataWithoutAnimation()
-
动态计算tableView内容总高度(不含contentInset,使用dataSource和delegate,必须实现heightForRow等方法),即使tableView未reloadData也会返回新高度
Declaration
Swift
@MainActor public func totalContentHeight() -> CGFloat
-
获取指定section的header视图frame,失败时为zero
Declaration
Swift
@MainActor public func layoutHeaderFrame(for section: Int) -> CGRect
-
获取指定section的footer视图frame,失败时为zero
Declaration
Swift
@MainActor public func layoutFooterFrame(for section: Int) -> CGRect
-
获取指定indexPath的cell视图frame,失败时为zero
Declaration
Swift
@MainActor public func layoutCellFrame(for indexPath: IndexPath) -> CGRect
-
判断indexPath是否有效
Declaration
Swift
@MainActor public func isValidIndexPath(_ indexPath: IndexPath) -> Bool
-
简单曝光方案,willDisplay调用即可,表格快速滑动、数据不变等情况不计曝光。如需完整曝光方案,请使用StatisticalView
Declaration
Swift
@MainActor public func willDisplay( _ cell: UITableViewCell, at indexPath: IndexPath, key: AnyHashable? = nil, exposure: @escaping @MainActor @Sendable () -> Void )
-
设置分割线内边距,iOS8+默认15.f,设为UIEdgeInsetsZero可去掉
Declaration
Swift
@MainActor public var separatorInset: UIEdgeInsets { get set }
-
调整imageView的位置偏移,默认zero不生效,仅支持default|subtitle样式
Declaration
Swift
@MainActor public var imageEdgeInsets: UIEdgeInsets { get set }
-
调整textLabel的位置偏移,默认zero不生效,仅支持default|subtitle样式
Declaration
Swift
@MainActor public var textEdgeInsets: UIEdgeInsets { get set }
-
调整detailTextLabel的位置偏移,默认zero不生效,仅支持subtitle样式
Declaration
Swift
@MainActor public var detailTextEdgeInsets: UIEdgeInsets { get set }
-
调整accessoryView的位置偏移,默认zero不生效,仅对自定义accessoryView生效
Declaration
Swift
@MainActor public var accessoryEdgeInsets: UIEdgeInsets { get set }
-
获取当前所属tableView
Declaration
Swift
@MainActor public weak var tableView: UITableView? { get }
-
获取当前显示indexPath
Declaration
Swift
@MainActor public var indexPath: IndexPath? { get }
-
执行所属tableView的批量更新
Declaration
Swift
@MainActor public func performBatchUpdates( _ updates: (@MainActor @Sendable (UITableView, IndexPath?) -> Void)?, completion: (@MainActor @Sendable (UITableView, IndexPath?, Bool) -> Void)? = nil )
-
reloadData完成回调
Declaration
Swift
@MainActor public func reloadData(completion: (@MainActor @Sendable () -> Void)?)
-
reloadData禁用动画
Declaration
Swift
@MainActor public func reloadDataWithoutAnimation()
-
获取指定indexPath的header视图frame,失败时为zero
Declaration
Swift
@MainActor public func layoutHeaderFrame(for indexPath: IndexPath) -> CGRect
-
获取指定indexPath的footer视图frame,失败时为zero
Declaration
Swift
@MainActor public func layoutFooterFrame(for indexPath: IndexPath) -> CGRect
-
获取指定indexPath的cell视图frame,失败时为zero
Declaration
Swift
@MainActor public func layoutCellFrame(for indexPath: IndexPath) -> CGRect
-
判断indexPath是否有效
Declaration
Swift
@MainActor public func isValidIndexPath(_ indexPath: IndexPath) -> Bool
-
计算指定indexPath的frame,并转换为指定视图坐标(nil时默认window)
Declaration
Swift
@MainActor public func layoutFrame(at indexPath: IndexPath, to view: UIView?) -> CGRect?
-
添加拖动排序手势,需结合canMove、moveItem、targetIndexPath使用
Declaration
Swift
@discardableResult @MainActor public func addMovementGesture(customBlock: (@MainActor @Sendable (UILongPressGestureRecognizer) -> Bool)? = nil) -> UILongPressGestureRecognizer
-
简单曝光方案,willDisplay调用即可,集合快速滑动、数据不变等情况不计曝光。如需完整曝光方案,请使用StatisticalView
Declaration
Swift
@MainActor public func willDisplay( _ cell: UICollectionViewCell, at indexPath: IndexPath, key: AnyHashable? = nil, exposure: @escaping @MainActor @Sendable () -> Void )
-
获取当前所属collectionView
Declaration
Swift
@MainActor public weak var collectionView: UICollectionView? { get }
-
获取当前显示indexPath
Declaration
Swift
@MainActor public var indexPath: IndexPath? { get }
-
执行所属collectionView的批量更新
Declaration
Swift
@MainActor public func performBatchUpdates( _ updates: (@MainActor @Sendable (UICollectionView, IndexPath?) -> Void)?, completion: (@MainActor @Sendable (UICollectionView, IndexPath?, Bool) -> Void)? = nil )
-
自定义内容边距,可调整左右距离和TextField高度,未设置时为系统默认
如需设置UISearchBar为navigationItem.titleView,请使用ExpandedTitleView
Declaration
Swift
@MainActor public var contentInset: UIEdgeInsets { get set }
-
自定义取消按钮边距,未设置时为系统默认
Declaration
Swift
@MainActor public var cancelButtonInset: UIEdgeInsets { get set }
-
输入框内部视图
Declaration
Swift
@MainActor public var textField: UISearchTextField { get }
-
取消按钮内部视图,showsCancelButton开启后才存在
Declaration
Swift
@MainActor public weak var cancelButton: UIButton? { get }
-
输入框的文字颜色
Declaration
Swift
@MainActor public var textColor: UIColor? { get set }
-
输入框的字体,会同时影响placeholder的字体
Declaration
Swift
@MainActor public var font: UIFont? { get set }
-
输入框内placeholder的颜色
Declaration
Swift
@MainActor public var placeholderColor: UIColor? { get set }
-
设置整体背景色
Declaration
Swift
@MainActor public var backgroundColor: UIColor? { get set }
-
设置输入框背景色
Declaration
Swift
@MainActor public var textFieldBackgroundColor: UIColor? { get set }
-
设置搜索图标离左侧的偏移位置,非居中时生效
Declaration
Swift
@MainActor public var searchIconOffset: CGFloat { get set }
-
设置清空图标离右侧的偏移位置
Declaration
Swift
@MainActor public var clearIconOffset: CGFloat { get set }
-
设置搜索文本离左侧图标的偏移位置
Declaration
Swift
@MainActor public var searchTextOffset: CGFloat { get set }
-
设置TextField搜索图标(placeholder)是否居中,否则居左
Declaration
Swift
@MainActor public var searchIconCenter: Bool { get set }
-
强制取消按钮一直可点击,需在showsCancelButton设置之后生效。默认SearchBar失去焦点之后取消按钮不可点击
Declaration
Swift
@MainActor public var forceCancelButtonEnabled: Bool { get set }
-
判断当前控制器是否是头部控制器。如果是导航栏的第一个控制器或者不含有导航栏,则返回YES
Declaration
Swift
@MainActor public var isHead: Bool { get }
-
判断当前控制器是否是尾部控制器。如果是导航栏的最后一个控制器或者不含有导航栏,则返回YES
Declaration
Swift
@MainActor public var isTail: Bool { get }
-
判断当前控制器是否是子控制器。如果父控制器存在,且不是导航栏或标签栏控制器,则返回YES
Declaration
Swift
@MainActor public var isChild: Bool { get }
-
判断当前控制器是否是present弹出。如果是导航栏的第一个控制器且导航栏是present弹出,也返回YES
Declaration
Swift
@MainActor public var isPresented: Bool { get }
-
判断当前控制器是否是iOS13+默认pageSheet弹出样式。该样式下导航栏高度等与默认样式不同
Declaration
Swift
@MainActor public var isPageSheet: Bool { get }
-
视图是否可见,viewWillAppear后为YES,viewDidDisappear后为NO
Declaration
Swift
@MainActor public var isViewVisible: Bool { get }
-
控制器是否可见,视图可见、尾部控制器、且不含presented控制器时为YES
Declaration
Swift
@MainActor public var isVisible: Bool { get }
-
获取祖先视图,标签栏存在时为标签栏根视图,导航栏存在时为导航栏根视图,否则为控制器根视图
Declaration
Swift
@MainActor public var ancestorView: UIView { get }
-
是否已经加载完数据,默认NO,加载数据完成后可标记为YES,可用于第一次加载时显示loading等判断
Declaration
Swift
@MainActor public var isDataLoaded: Bool { get set }
-
移除子控制器,解决不能触发viewWillAppear等的bug
Declaration
Swift
@MainActor public func removeChild(_ viewController: UIViewController)
-
添加子控制器到指定视图,解决不能触发viewWillAppear等的bug
Declaration
Swift
@MainActor public func addChild(_ viewController: UIViewController, in view: UIView? = nil, layout: (@MainActor (UIView) -> Void)? = nil)
-
弹出popover控制器
Declaration
Swift
@MainActor public func presentPopover( _ popover: UIViewController, sourcePoint: CGPoint, size: CGSize? = nil, delegate: (any UIPopoverPresentationControllerDelegate)? = nil, animated: Bool = true, completion: (@MainActor @Sendable () -> Void)? = nil )
-
从 appearance 里取值并赋值给当前实例,通常在对象的 init 里调用。支持的属性需标记为\@objc dynamic才生效
Declaration
Swift
public func applyAppearance()
-
利用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公钥加密,数据传输安全,使用默认标签,执行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?
-
显示骨架屏,指定布局代理
Declaration
Swift
@MainActor public func showSkeleton(delegate: SkeletonViewDelegate?)
-
显示骨架屏,指定布局句柄
Declaration
Swift
@MainActor public func showSkeleton(block: (@MainActor (SkeletonLayout) -> Void)?)
-
显示骨架屏,默认布局代理为self
Declaration
Swift
@MainActor public func showSkeleton()
-
隐藏骨架屏
Declaration
Swift
@MainActor public func hideSkeleton()
-
是否正在显示骨架屏
Declaration
Swift
@MainActor public var hasSkeleton: Bool { get }
-
显示view骨架屏,指定布局代理
Declaration
Swift
@MainActor public func showSkeleton(delegate: SkeletonViewDelegate?)
-
显示view骨架屏,指定布局句柄
Declaration
Swift
@MainActor public func showSkeleton(block: (@MainActor (SkeletonLayout) -> Void)?)
-
显示view骨架屏,默认布局代理为self
Declaration
Swift
@MainActor public func showSkeleton()
-
隐藏view骨架屏
Declaration
Swift
@MainActor public func hideSkeleton()
-
是否正在显示view骨架屏
Declaration
Swift
@MainActor public var hasSkeleton: Bool { get }
-
设置并尝试自动绑定点击事件统计
Declaration
Swift
@MainActor public var statisticalClick: StatisticalEvent? { get set }
-
设置统计点击事件触发时自定义监听器,默认nil
Declaration
Swift
@MainActor public var statisticalClickListener: ((StatisticalEvent) -> Void)? { get set }
-
手工绑定点击事件统计,可指定容器视图,自动绑定失败时可手工调用
Declaration
Swift
@discardableResult @MainActor public func statisticalBindClick(_ containerView: UIView? = nil) -> Bool
-
触发视图点击事件统计,仅绑定statisticalClick后生效
Declaration
Swift
@discardableResult @MainActor public func statisticalTrackClick(indexPath: IndexPath? = nil, event: StatisticalEvent? = nil) -> Bool
-
设置并尝试自动绑定曝光事件统计。如果对象发生变化(indexPath|name|object),也会触发
Declaration
Swift
@MainActor public var statisticalExposure: StatisticalEvent? { get set }
-
设置统计曝光事件触发时自定义监听器,默认nil
Declaration
Swift
@MainActor public var statisticalExposureListener: ((StatisticalEvent) -> Void)? { get set }
-
手工绑定曝光事件统计,可指定容器视图,自动绑定失败时可手工调用
Declaration
Swift
@discardableResult @MainActor public func statisticalBindExposure(_ containerView: UIView? = nil) -> Bool
-
触发视图曝光事件统计,仅绑定statisticalExposure后生效
Declaration
Swift
@discardableResult @MainActor public func statisticalTrackExposure(indexPath: IndexPath? = nil, isFinished: Bool = false, event: StatisticalEvent? = nil) -> Bool
-
检查并更新视图曝光状态,用于自定义场景
Declaration
Swift
@MainActor public func statisticalCheckExposure()
-
设置并尝试自动绑定曝光事件统计
Declaration
Swift
@MainActor public var statisticalExposure: StatisticalEvent? { get set }
-
设置统计曝光事件触发时自定义监听器,默认nil
Declaration
Swift
@MainActor public var statisticalExposureListener: ((StatisticalEvent) -> Void)? { get set }
-
触发控制器曝光事件统计,仅绑定statisticalExposure后生效
Declaration
Swift
@discardableResult @MainActor public func statisticalTrackExposure(isFinished: Bool = false, event: StatisticalEvent? = nil) -> Bool
-
检查并更新控制器曝光状态,用于自定义场景
Declaration
Swift
@MainActor public func statisticalCheckExposure()
-
获取设备IDFA(外部使用),重置广告或系统后会改变,需先检测广告追踪权限
Declaration
Swift
public nonisolated static var deviceIDFA: String { get }