DTBKitStaticWrapper

public struct DTBKitStaticWrapper<T>

Mainly static wrapper.

静态方法容器。

  • Undocumented

    Declaration

    Swift

    public init()

Available where T: Bundle

  • Will enumerator main path.

    在 main bundle 下的全路径中搜索并创建 bundle.

    Declaration

    Swift

    public func create(_ name: String, cacheable: Bool = true) -> Bundle?

    Parameters

    name

    bundle name.

    cacheable

    use bundleIdentifier to cache.

    Return Value

    Bundle

Available where T: UserDefaults

  • Declaration

    Swift

    public func clear<Value>(_ key: DTB.ConstKey<Value>)

Original

  • Undocumented

    Declaration

    Swift

    public func isVaild<Value>(_ key: DTB.ConstKey<Value>) -> Bool
  • Declaration

    Swift

    public func read<Value>(_ key: DTB.ConstKey<Value>) -> Value?
  • Declaration

    Swift

    public func write<Value>(_ value: Value?, key: DTB.ConstKey<Value>)

Codable

  • Undocumented

    Declaration

    Swift

    public func read<Value>(codable key: DTB.ConstKey<Value>) -> Value? where Value : Decodable, Value : Encodable
  • Declaration

    Swift

    public func write<Value>(codable: Value, key: DTB.ConstKey<Value>) where Value : Decodable, Value : Encodable

Available where T: NumberFormatter

  • Declaration

    Swift

    public var fixed: NumberFormatter { get }
  • Declaration

    Swift

    public var multi: NumberFormatter { get }
  • CNY

    Declaration

    Swift

    public var CNY: NumberFormatter { get }
  • RMB

    Declaration

    Swift

    public var RMB: NumberFormatter { get }

Available where T: UIColor

  • Darkable hex color

    sample: 0xFF8534 -> UIColor

    Declaration

    Swift

    public func hex(_ def: Int64, alpha: CGFloat = 1.0, dark: Int64? = nil, darkAlpha: CGFloat? = nil) -> UIColor

Available where T: UIImage

  • Create resource image by name.

    • Proj.xcassets

      • same as UIImage(named:)
    • Proj.main

      • when you put image in main proj source code
    • Proj.main/*.bundle/*.*

      • when you put bundle in main proj source code
    • Proj.main/*.bundle/*.{xcassets, car}/*.*

      • when you use *.xcassets in custom bundle
    • Proj.{SPM, Pods, framework, ...}/

      • when your code is third part

    refer

    Declaration

    Swift

    public func create(_ imageName: String?, bundle: Bundle? = nil) -> UIImage?

    Parameters

    imageName

    imageName description

    bundle

    bundle description

    Return Value

    description

Available where T: UIViewController

  • Recursion get the top most view controller.

    递归取栈顶。

    Declaration

    Swift

    public func topMost() -> UIViewController?
  • Try pop / dismiss / remove top most view controller

    依次尝试各种方法去移除 topMost,在诸如 WKWebView 内部的场景下可能会用到。

    Declaration

    Swift

    @discardableResult
    public func popAnyway(animated: Bool = true) -> Bool

    Return Value

    success == true

Available where T: UIWindowScene

  • Current scene in general.

    scene,注定无法准确,用前请读最佳实践。

    best practices refer

    Declaration

    Swift

    @available(iOS 13.0, *)
    public func current() -> DTBKitWrapper<UIWindowScene>?

Available where T: UIWindow

Available where T == CLLocationCoordinate2D

  • WGS-84 –> GCJ-02

    Declaration

    Swift

    public func getGCJFromWGS(_ p: CLLocationCoordinate2D) -> CLLocationCoordinate2D
  • GCJ-02 –> WGS-84

    Declaration

    Swift

    public func getWGSFromGCJ(_ p: CLLocationCoordinate2D) -> CLLocationCoordinate2D
  • GCJ –> Baidu

    Declaration

    Swift

    public func getBDFromGCJ(_ p: CLLocationCoordinate2D) -> CLLocationCoordinate2D
  • Baidu –> GCJ

    Declaration

    Swift

    public func getGCJFromBD(_ p: CLLocationCoordinate2D) -> CLLocationCoordinate2D
  • WGS –> Baidu

    Declaration

    Swift

    public func getBDFromWGS(_ p: CLLocationCoordinate2D) -> CLLocationCoordinate2D
  • Baidu –> WGS

    Declaration

    Swift

    public func getWGSFromBD(_ p: CLLocationCoordinate2D) -> CLLocationCoordinate2D
  • 不在中国区域内 (估算)

    Declaration

    Swift

    public func notInChina(_ p: CLLocationCoordinate2D) -> Bool
  • 获取两点之间的距离 (米)

    Declaration

    Swift

    public func distanceBetween(p1: CLLocationCoordinate2D, p2: CLLocationCoordinate2D) -> CLLocationDistance