harry 3 rokov pred
rodič
commit
685094c2f4

+ 0 - 176
BFCommonKit/Classes/BFCategorys/BFUIButton+ext.swift

@@ -1,176 +0,0 @@
-//
-//  UIButton+ext.swift
-//  PQSpeed
-//
-//  Created by ak on 2020/8/14.
-//  Copyright © 2020 BytesFlow. All rights reserved.
-//
-/**
- UIButton图像文字同时存在时---图像相对于文字的位置
-
- - top:    图像在上
- - left:   图像在左
- - right:  图像在右
- - bottom: 图像在下
- */
-public enum PQButtonImageEdgeInsetsStyle {
-    case top, left, right, bottom
-}
-
-import Foundation
-public extension UIButton {
-    func imagePosition(at style: PQButtonImageEdgeInsetsStyle, space: CGFloat) {
-        guard let imageV = imageView else { return }
-        guard let titleL = titleLabel else { return }
-        // 获取图像的宽和高
-        let imageWidth = imageV.frame.size.width
-        let imageHeight = imageV.frame.size.height
-        // 获取文字的宽和高
-        let labelWidth = titleL.frame.size.width
-        let labelHeight = titleL.frame.size.height
-
-        var imageEdgeInsets = UIEdgeInsets.zero
-        var labelEdgeInsets = UIEdgeInsets.zero
-        // UIButton同时有图像和文字的正常状态---左图像右文字,间距为0
-        switch style {
-        case .left:
-            // 正常状态--只不过加了个间距
-            imageEdgeInsets = UIEdgeInsets(top: 0, left: -space * 0.5, bottom: 0, right: space * 0.5)
-            labelEdgeInsets = UIEdgeInsets(top: 0, left: space * 0.5, bottom: 0, right: -space * 0.5)
-        case .right:
-            // 切换位置--左文字右图像
-            // 图像:UIEdgeInsets的left是相对于UIButton的左边移动了labelWidth + space * 0.5,right相对于label的左边移动了-labelWidth - space * 0.5
-            imageEdgeInsets = UIEdgeInsets(top: 0, left: labelWidth + space * 0.5, bottom: 0, right: -labelWidth - space * 0.5)
-            labelEdgeInsets = UIEdgeInsets(top: 0, left: -imageWidth - space * 0.5, bottom: 0, right: imageWidth + space * 0.5)
-        case .top:
-            // 切换位置--上图像下文字
-            /** 图像的中心位置向右移动了labelWidth * 0.5,向上移动了-imageHeight * 0.5 - space * 0.5
-              *文字的中心位置向左移动了imageWidth * 0.5,向下移动了labelHeight*0.5+space*0.5
-             */
-            imageEdgeInsets = UIEdgeInsets(top: -(imageHeight * 0.5 - space), left: labelWidth * 0.5, bottom: imageHeight * 0.5 - space, right: -labelWidth * 0.5)
-            labelEdgeInsets = UIEdgeInsets(top: labelHeight * 0.5 + space * 2, left: -imageWidth * 0.5, bottom: -(labelHeight * 0.5 + space * 2), right: imageWidth * 0.5)
-        case .bottom:
-            // 切换位置--下图像上文字
-            /** 图像的中心位置向右移动了labelWidth * 0.5,向下移动了imageHeight * 0.5 + space * 0.5
-             *文字的中心位置向左移动了imageWidth * 0.5,向上移动了labelHeight*0.5+space*0.5
-             */
-            imageEdgeInsets = UIEdgeInsets(top: imageHeight * 0.5 + space * 0.5, left: labelWidth * 0.5, bottom: -imageHeight * 0.5 - space * 0.5, right: -labelWidth * 0.5)
-            labelEdgeInsets = UIEdgeInsets(top: -labelHeight * 0.5 - space * 0.5, left: -imageWidth * 0.5, bottom: labelHeight * 0.5 + space * 0.5, right: imageWidth * 0.5)
-        }
-        titleEdgeInsets = labelEdgeInsets
-        self.imageEdgeInsets = imageEdgeInsets
-    }
-}
-
-/*
-   e.g.
- let button = UIButton(frame: CGRect(x: 0, y: 300, width: 100, height: 22))
- button.setTitle("按钮", for: .normal)
- button.setTitleColor(.black, for: .normal)
- button.eventInterval = 2.0  //  按的时间间隔, 设置为0的时候就是可以反复点击
- view.addSubview(button)
- 
- */
-// MARK: - 按钮的反复点击问题 交换方法
-extension UIButton {
-
-    /// 对外交换方法的方法 AppDelegate Launch中使用
-    public  static func methodExchange() {
-        DispatchQueue.once(token: "UIButton") {
-            let originalSelector = Selector.sysFunc
-            let swizzledSelector = Selector.myFunc
-            changeMethod(originalSelector, swizzledSelector, self)
-        }
-    }
-    
-    
-    /// Runtime方法交换
-    ///
-    /// - Parameters:
-    ///   - original: 原方法
-    ///   - swizzled: 交换方法
-    ///   - object: 对象
-    public static func changeMethod(_ original: Selector, _ swizzled: Selector, _ object: AnyClass) -> () {
-        
-        guard let originalMethod = class_getInstanceMethod(object, original),
-              let swizzledMethod = class_getInstanceMethod(object, swizzled) else {
-            return
-        }
-        
-        let didAddMethod = class_addMethod(object, original, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))
-        if didAddMethod {
-            class_replaceMethod(object, swizzled, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod))
-        } else {
-            method_exchangeImplementations(originalMethod, swizzledMethod)
-        }
-    }
-    
-    
-    /// 结构体静态key
-    public struct UIButtonKey {
-        static var isEventUnavailableKey = "isEventUnavailableKey"
-        static var eventIntervalKey = "eventIntervalKey"
-    }
-    
-    /// 触发事件的间隔
-    public var eventInterval: TimeInterval {
-        get {
-            return (objc_getAssociatedObject(self, &UIButtonKey.eventIntervalKey) as? TimeInterval) ?? 0
-        }
-        set {
-            objc_setAssociatedObject(self, &UIButtonKey.eventIntervalKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
-        }
-    }
-    
-    /// 是否可以触发事件
-    fileprivate var isEventUnavailable: Bool {
-        get {
-            return (objc_getAssociatedObject(self, &UIButtonKey.isEventUnavailableKey) as? Bool) ?? false
-        }
-        set {
-            objc_setAssociatedObject(self, &UIButtonKey.isEventUnavailableKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
-        }
-    }
-    
-    /// 手写的set方法
-    ///
-    /// - Parameter isEventUnavailable: 事件是否可用
-    @objc private func setIsEventUnavailable(_ isEventUnavailable: Bool) {
-        self.isEventUnavailable = isEventUnavailable
-    }
-    
-    /// mySendAction
-    @objc fileprivate func mySendAction(_ action: Selector, to target: Any?, for event: UIEvent?) {
-        print("交换了按钮事件的方法")
-        
-        if isEventUnavailable == false {
-            isEventUnavailable = true
-            mySendAction(action, to: target, for: event)
-            perform(#selector(setIsEventUnavailable(_: )), with: false, afterDelay: eventInterval)
-        }
-    }
-}
-
-fileprivate extension Selector {
-    static let sysFunc = #selector(UIButton.sendAction(_:to:for:))
-    static let myFunc = #selector(UIButton.mySendAction(_:to:for:))
-}
-
-extension DispatchQueue {
-    private static var onceTracker = [String]()
-    
-    open class func once(token: String, block:() -> ()) {
-        //注意defer作用域,调用顺序——即一个作用域结束,该作用域中的defer语句自下而上调用。
-        objc_sync_enter(self)
-        defer {
-            print("线程锁退出")
-            objc_sync_exit(self)
-        }
-        
-        if onceTracker.contains(token) {
-            return
-        }
-        onceTracker.append(token)
-        block()
-    }
-}

+ 0 - 296
BFCommonKit/Classes/BFCategorys/BFUIImage+Ext.swift

@@ -1,296 +0,0 @@
-//
-//  UIImage+Ext.swift
-//  PQSpeed
-//
-//  Created by SanW on 2020/6/19.
-//  Copyright © 2020 BytesFlow. All rights reserved.
-//
-
-import Foundation
-
-public extension UIImage {
-    // 从BFframwork bundle 中取图片
-    static func mc_loadImage(_ imageName: String, from bundleName: String, in podName: String) -> UIImage? {
-            
-            var associateBundleURL = Bundle.main.url(forResource: "Frameworks", withExtension: nil)
-            associateBundleURL = associateBundleURL?.appendingPathComponent(podName)
-            associateBundleURL = associateBundleURL?.appendingPathExtension("framework")
-            
-            
-            if associateBundleURL == nil {
-                print("获取bundle失败")
-                return nil
-            }
-            
-            let associateBunle = Bundle.init(url: associateBundleURL!)
-            associateBundleURL = associateBunle?.url(forResource: bundleName, withExtension: "bundle")
-            
-            if associateBundleURL != nil {
-                let bundle = Bundle.init(url: associateBundleURL!)
-                let scale = Int(UIScreen.main.scale)
-                
-                // 适配2x还是3x图片
-                let name = imageName + "@" + String(scale) + "x"
-                let path = bundle?.path(forResource: name, ofType: "png")
-                
-                if path == nil {
-                    print("获取bundle失败")
-                    return nil
-                }
-                let image1 = UIImage.init(contentsOfFile: path!)
-                return image1
-
-            } else {
-                return nil
-            }
-        }
-    
-    
-    func BF_Image(named: String) -> UIImage {
-        let image: UIImage = UIImage(named: named, in: Bundle().BF_mainbundle(), compatibleWith: nil) ?? UIImage()
-        return image
-    }
-
-    class func moduleImage(named: String, moduleName: String,isAssets:Bool = true) -> UIImage? {
-        let image: UIImage? = UIImage(named: named, in: Bundle.current(moduleName: moduleName,isAssets: isAssets), compatibleWith: nil)
-        return image
-    }
-
-    func cropImage(ratio: CGFloat) -> UIImage {
-        // 计算最终尺寸
-        let newSize: CGSize = CGSize(width: size.width, height: size.width * ratio)
-        // 图片绘制区域
-        var rect = CGRect.zero
-        rect.size.width = size.width
-        rect.size.height = size.height
-        rect.origin.x = (newSize.width - size.width) / 2.0
-        rect.origin.y = (newSize.height - size.height) / 2.0
-
-        UIGraphicsBeginImageContext(newSize)
-        draw(in: rect)
-        let scaledImage = UIGraphicsGetImageFromCurrentImageContext()
-        UIGraphicsEndImageContext()
-
-        return scaledImage!
-    }
-
-    func cropImage(newSize: CGSize) -> UIImage {
-        //// 图片绘制区域
-        var rect = CGRect.zero
-        rect.size.width = newSize.width
-        rect.size.height = newSize.width * (size.height / size.width)
-        // 绘制并获取最终图片
-        UIGraphicsBeginImageContext(newSize)
-        draw(in: rect)
-        let scaledImage = UIGraphicsGetImageFromCurrentImageContext()
-        UIGraphicsEndImageContext()
-
-        return scaledImage!
-    }
-
-    func imageWithImage(scaledToSize newSize: CGSize) -> UIImage {
-        UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0)
-        draw(in: CGRect(origin: CGPoint.zero, size: newSize))
-        let newImage = UIGraphicsGetImageFromCurrentImageContext() ?? self
-        UIGraphicsEndImageContext()
-        return newImage
-    }
-
-    /// 旋转角度
-    /// - Parameter image: <#image description#>
-    /// - Returns: <#description#>
-    func rotateImage(rotate: Int, originWidth: CGFloat, originHeight: CGFloat) -> UIImage {
-        let rotate: CGFloat = CGFloat(3 * Double.pi / 2)
-        let rect = CGRect(x: 0, y: 0, width: originWidth, height: originHeight)
-        let translateX: CGFloat = -rect.size.height
-        let translateY: CGFloat = 0
-        let scaleY = rect.size.width / rect.size.height
-        let scaleX = rect.size.height / rect.size.width
-        UIGraphicsBeginImageContext(rect.size)
-        let context = UIGraphicsGetCurrentContext()
-        //        context!.translateBy(x: 0.0, y: rect.size.height)
-        //        context!.scaleBy(x: 1.0, y: -1.0)
-        context!.rotate(by: rotate)
-        context!.translateBy(x: translateX, y: translateY)
-        context!.scaleBy(x: scaleX, y: scaleY)
-        draw(in: CGRect(x: 0, y: 0, width: rect.size.width, height: rect.size.height))
-        return UIGraphicsGetImageFromCurrentImageContext()!
-    }
-
-    /// 生成三角图
-    /// - Parameters:
-    ///   - size: <#size description#>
-    ///   - tintColor: <#tintColor description#>
-    ///   - convert:是否倒置
-    /// - Returns: <#description#>
-    class func triangleImage(size: CGSize, tintColor: UIColor, direction: moveDirection = .moveDirectionDown) -> UIImage {
-        var startPoint: CGPoint = CGPoint.zero
-        var middlePoint: CGPoint = CGPoint.zero
-        var endPoint: CGPoint = CGPoint.zero
-        switch direction {
-        case .moveDirectionLeft:
-            startPoint = CGPoint(x: size.width, y: 0)
-            middlePoint = CGPoint(x: 0, y: size.height / 2.0)
-            endPoint = CGPoint(x: size.width, y: size.height)
-        case .moveDirectionRight:
-            startPoint = CGPoint(x: 0, y: 0)
-            middlePoint = CGPoint(x: size.width, y: size.height / 2.0)
-            endPoint = CGPoint(x: 0, y: size.height)
-        case .moveDirectionUp:
-            startPoint = CGPoint(x: 0, y: size.height)
-            middlePoint = CGPoint(x: size.width / 2.0, y: 0)
-            endPoint = CGPoint(x: size.width, y: size.height)
-        default:
-            startPoint = CGPoint(x: 0, y: 0)
-            middlePoint = CGPoint(x: size.width / 2.0, y: size.height)
-            endPoint = CGPoint(x: size.width, y: 0)
-        }
-        UIGraphicsBeginImageContextWithOptions(size, false, 0)
-        let ctx = UIGraphicsGetCurrentContext()
-        let path = UIBezierPath()
-        path.move(to: startPoint)
-        path.addLine(to: middlePoint)
-        path.addLine(to: endPoint)
-        path.close()
-        ctx?.setFillColor(tintColor.cgColor)
-        path.fill()
-        let image = UIGraphicsGetImageFromCurrentImageContext()!
-        UIGraphicsEndImageContext()
-        return image
-    }
-
-    /// 按照最短边缩放  add by ak
-    /// - Parameter maxLength: 边长最大值
-    func nx_scaleWithMaxLength(maxLength: CGFloat) -> UIImage {
-        if size.width > maxLength || size.height > maxLength {
-            var maxWidth: CGFloat = maxLength
-            var maxHeight: CGFloat = maxLength
-
-            if size.width != size.height {
-                if size.width > size.height {
-                    // 按照宽 来缩放
-                    let imageScale: CGFloat = maxLength / size.width
-
-                    maxHeight = size.height * imageScale
-                } else if size.width < size.height {
-                    let imageScale: CGFloat = maxLength / size.height
-
-                    maxWidth = size.width * imageScale
-                }
-            }
-            // 返回新的改变大小后的图片
-            return nx_scaleToSize(size: CGSize(width: maxWidth, height: maxHeight))
-        }
-
-        return self
-    }
-
-    /// 缩放到指定大小 add by ak
-    /// - Parameter size: 新的大小
-    func nx_scaleToSize(size: CGSize) -> UIImage {
-        var width: CGFloat = CGFloat(cgImage!.width)
-        var height: CGFloat = CGFloat(cgImage!.height)
-
-        let verticalRadio: CGFloat = size.height * 1.0 / height
-        let horizontalRadio: CGFloat = size.width * 1.0 / width
-
-        var radio: CGFloat = 1
-        if verticalRadio > 1, horizontalRadio > 1 {
-            radio = verticalRadio > horizontalRadio ? horizontalRadio : verticalRadio
-        } else {
-            radio = verticalRadio < horizontalRadio ? verticalRadio : horizontalRadio
-        }
-
-        width = width * radio
-        height = height * radio
-
-        let xPos: CGFloat = (size.width - width) / 2
-        let yPos: CGFloat = (size.height - height) / 2
-
-        // 创建一个bitmap的context
-        // 并把它设置成为当前正在使用的context
-        UIGraphicsBeginImageContext(size)
-
-        // 绘制改变大小的图片
-        var rect = CGRect.zero
-        rect.size.width = width
-        rect.size.height = height
-        rect.origin.x = xPos
-        rect.origin.y = yPos
-
-        draw(in: rect)
-
-        // 从当前context中创建一个改变大小后的图片
-        let scaledImage: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
-
-        // 使当前的context出堆栈
-        UIGraphicsEndImageContext()
-
-        // 返回新的改变大小后的图片
-        return scaledImage
-    }
-
-    // 将图片裁剪成指定比例(多余部分自动删除)let image3 = image.crop(ratio: 1) /将图片转成 1:1 比例(正方形)
-    func nxcrop(ratio: CGFloat) -> UIImage {
-        // 计算最终尺寸
-        var newSize: CGSize!
-        if size.width / size.height > ratio {
-            newSize = CGSize(width: size.height * ratio, height: size.height)
-        } else {
-            newSize = CGSize(width: size.width, height: size.width / ratio)
-        }
-
-        ////图片绘制区域
-        var rect = CGRect.zero
-        rect.size.width = size.width
-        rect.size.height = size.height
-        rect.origin.x = (newSize.width - size.width) / 2.0
-        rect.origin.y = (newSize.height - size.height) / 2.0
-
-        // 绘制并获取最终图片
-        UIGraphicsBeginImageContext(newSize)
-        draw(in: rect)
-        let scaledImage = UIGraphicsGetImageFromCurrentImageContext()
-        UIGraphicsEndImageContext()
-
-        return scaledImage!
-    }
-
-    /// 改变图片主题颜色
-    /// - Parameters:
-    ///   - color: <#color description#>
-    ///   - blendMode: <#blendMode description#>
-    /// - Returns: <#description#>
-    func tintImage(color: UIColor, blendMode: CGBlendMode) -> UIImage? {
-        let rect = CGRect(origin: CGPoint.zero, size: size)
-        UIGraphicsBeginImageContextWithOptions(size, false, scale)
-        color.setFill()
-        UIRectFill(rect)
-        draw(in: rect, blendMode: blendMode, alpha: 1.0)
-        let tintedImage = UIGraphicsGetImageFromCurrentImageContext()
-        UIGraphicsEndImageContext()
-        return tintedImage
-    }
-    
-    /// 保存图片文件到指定目录, 如果目录已经存在会先删除老文件
-    /// - Parameters:
-    ///   - currentImage: 图片数据
-    ///   - persent: 质量
-    ///   - outFilePath: 输出目录
-    class func saveImage(currentImage: UIImage,outFilePath: String) {
-        // 文件存在先删除老文件
-        if FileManager.default.fileExists(atPath: outFilePath) {
-            do {
-                try FileManager.default.removeItem(at: NSURL.fileURL(withPath: outFilePath))
-            } catch {
-                BFLog(message: "删除文件出错 == \(error) \(outFilePath)")
-            }
-        }
-        
-        if let imageData = currentImage.pngData() {
-            try? imageData.write(to: URL(fileURLWithPath: outFilePath))
-            print("保存图片成功到:filePath=\(outFilePath)")
-        }
-    }
-
-}

+ 0 - 419
BFCommonKit/Classes/BFCategorys/BFUIView+Ext.swift

@@ -1,419 +0,0 @@
-//
-//  UICollectionView+Ext.swift
-//  PQSpeed
-//
-//  Created by SanW on 2020/6/6.
-//  Copyright © 2020 BytesFlow. All rights reserved.
-//
-
-import KingfisherWebP
-import UIKit
-
-// MARK: - UIView的分类扩展
-
-/// UIView的分类扩展
-public extension UIView {
-    func addCorner(roundingCorners: UIRectCorner = .allCorners, corner: CGFloat = 10) {
-        if roundingCorners == .allCorners {
-            layer.cornerRadius = corner
-            layer.masksToBounds = true
-        } else {
-            let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: roundingCorners, cornerRadii: CGSize(width: corner, height: corner))
-            let cornerLayer = CAShapeLayer()
-            cornerLayer.frame = bounds
-            cornerLayer.path = path.cgPath
-            layer.mask = cornerLayer
-        }
-    }
-
-    /// 添加阴影
-    /// - Parameters:
-    ///   - color: <#color description#>
-    ///   - offset: <#offset description#>
-    /// - Returns: <#description#>
-    func addShadowLayer(isAll: Bool = false, color: UIColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5), offset: CGSize = CGSize(width: 1, height: 1)) {
-        layer.shadowColor = color.cgColor
-        layer.shadowOffset = offset
-        layer.shadowRadius = 0.5
-        layer.shadowOpacity = 1.0
-        if isAll {
-            layer.shadowColor = color.cgColor
-            layer.shadowOffset = CGSize.zero
-            // 设置偏移量为0,四周都有阴影
-            layer.shadowRadius = 0.5 // 阴影半径
-            layer.shadowOpacity = 0.3 // 阴影透明度
-            layer.masksToBounds = false
-            layer.shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: layer.cornerRadius).cgPath
-        }
-    }
-
-    /// 添加虚线条
-    func addBorderToLayer(frame: CGRect? = nil) {
-        // 线条颜色
-        let borderLayer: CAShapeLayer = CAShapeLayer()
-        borderLayer.strokeColor = UIColor.hexColor(hexadecimal: "#FFFFFF").cgColor
-        borderLayer.fillColor = nil
-        borderLayer.path = UIBezierPath(rect: frame == nil ? bounds : frame!).cgPath
-        borderLayer.frame = bounds
-        borderLayer.lineWidth = 2.0
-        borderLayer.lineCap = .round
-        // 第一位是 线条长度   第二位是间距 nil时为实线
-        borderLayer.lineDashPattern = [5, 5]
-        layer.addSublayer(borderLayer)
-    }
-
-    func animateZoom() {
-        transform = CGAffineTransform(scaleX: 0.4, y: 0.4)
-        UIView.animate(withDuration: 0.5, animations: {
-            self.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)
-        }) { _ in
-            UIView.animate(withDuration: 0.5, animations: {
-                self.transform = .identity
-            }) { _ in
-            }
-        }
-    }
-
-    /// 添加抖动功能
-    /// - Parameters:
-    ///   - fromValue: <#fromValue description#>
-    ///   - toValue: <#toValue description#>
-    ///   - duration: <#duration description#>
-    ///   - repeatCount: <#repeatCount description#>
-    /// - Returns: <#description#>
-    func shakeAnimation(_ fromValue: Float, _ toValue: Float, _ duration: Float, _: Float) {
-        layer.removeAllAnimations()
-        let shake = CABasicAnimation(keyPath: "transform.rotation.z")
-        shake.fromValue = fromValue
-        shake.toValue = toValue
-        shake.duration = CFTimeInterval(duration)
-        shake.autoreverses = true
-        shake.repeatCount = Float(CGFloat.greatestFiniteMagnitude)
-        shake.isRemovedOnCompletion = false
-        layer.add(shake, forKey: "imageView")
-        // 增加锚点
-        layer.anchorPoint = CGPoint(x: 0.5, y: 1)
-    }
-
-    /// 添加心跳动画
-    /// - Parameters:
-    ///   - duration: <#duration description#>
-    ///   - isRepeat: <#isRepeat description#>
-    ///   - multiple: <#multiple description#>
-    /// - Returns: <#description#>
-    func heartbeatAnimate(duration: TimeInterval, isRepeat: Bool, multiple: CGFloat) {
-        UIView.animateKeyframes(withDuration: duration, delay: 0, options: .allowUserInteraction, animations: {
-            self.transform = CGAffineTransform(scaleX: 1.0 + multiple, y: 1.0 + multiple)
-        }) { _ in
-            UIView.animateKeyframes(withDuration: duration, delay: 0, options: .allowUserInteraction, animations: {
-                self.transform = .identity
-            }) { _ in
-                UIView.animateKeyframes(withDuration: duration, delay: 0, options: .allowUserInteraction, animations: {
-                    self.transform = CGAffineTransform(scaleX: 1.0 + multiple * 2, y: 1.0 + multiple * 2)
-                }) { _ in
-                    UIView.animateKeyframes(withDuration: duration, delay: 0, options: .allowUserInteraction, animations: {
-                        self.transform = .identity
-                    }) { _ in
-                        if isRepeat {
-                            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 2.3) {
-                                self.heartbeatAnimate(duration: duration, isRepeat: isRepeat, multiple: multiple)
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /// 活动心跳动画
-    /// - Returns: <#description#>
-    func activityHeartbeatAnimate() {
-        layer.removeAllAnimations()
-        UIView.animateKeyframes(withDuration: 0.45, delay: 0, options: .allowUserInteraction, animations: {
-            self.transform = CGAffineTransform(scaleX: 0.9, y: 0.9)
-        }) { _ in
-            UIView.animateKeyframes(withDuration: 0.45, delay: 0, options: .allowUserInteraction, animations: {
-                self.transform = .identity
-            }) { _ in
-                self.activityHeartbeatAnimate()
-            }
-        }
-    }
-
-    /// 活动心跳动画
-    /// - Returns: <#description#>
-    func heartbeatAnimate() {
-        layer.removeAllAnimations()
-        UIView.animateKeyframes(withDuration: 1, delay: 0, options: .allowUserInteraction, animations: {
-            self.transform = CGAffineTransform(scaleX: 1.3, y: 1.3)
-        }) { isFinished in
-            UIView.animateKeyframes(withDuration: 1, delay: 0, options: .allowUserInteraction, animations: {
-                self.transform = .identity
-            }) { isFinished in
-                if isFinished {
-                    self.heartbeatAnimate()
-                }
-            }
-        }
-    }
-
-    func addScaleBasicAnimation() {
-        let animation = CABasicAnimation(keyPath: "transform.scale")
-        animation.timingFunction = CAMediaTimingFunction(name: .easeOut)
-        animation.duration = 0.5
-        animation.repeatCount = 1000
-        animation.autoreverses = true
-        animation.fromValue = 0.8
-        animation.toValue = 1.1
-        layer.add(animation, forKey: nil)
-    }
-
-    func addScaleYBasicAnimation() {
-        let animation = CAKeyframeAnimation(keyPath: "transform.translation.y")
-        animation.duration = 0.5
-        animation.repeatCount = 100
-        animation.isRemovedOnCompletion = true
-        //        animation.
-        animation.timingFunction = CAMediaTimingFunction(name: .easeOut)
-        layer.add(animation, forKey: nil)
-        //            CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.y"];
-        //            CGFloat duration = 1.f;
-        //            CGFloat height = 7.f;
-        //            CGFloat currentY = self.animationView.transform.ty;
-        //            animation.duration = duration;
-        //            animation.values = @[@(currentY),@(currentY - height/4),@(currentY - height/4*2),@(currentY - height/4*3),@(currentY - height),@(currentY - height/ 4*3),@(currentY - height/4*2),@(currentY - height/4),@(currentY)];
-        //            animation.keyTimes = @[ @(0), @(0.025), @(0.085), @(0.2), @(0.5), @(0.8), @(0.915), @(0.975), @(1) ];
-        //            animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
-        //            animation.repeatCount = HUGE_VALF;
-        //            [self.animationView.layer addAnimation:animation forKey:@"kViewShakerAnimationKey"];
-        //        }
-    }
-
-    /// 将view生成一张图片
-    /// - Returns: <#description#>
-    func graphicsGetImage() -> UIImage? {
-        UIGraphicsBeginImageContextWithOptions(frame.size, true, 0.0)
-        layer.render(in: UIGraphicsGetCurrentContext()!)
-        let newImage = UIGraphicsGetImageFromCurrentImageContext()
-        UIGraphicsEndImageContext()
-        return newImage
-    }
-
-    /// 动画显示View
-    /// - Returns: <#description#>
-    func showViewAnimate(duration: TimeInterval = 0.3, completion: ((Bool) -> Void)? = nil) {
-        UIView.animate(withDuration: duration, animations: { [weak self] in
-            self?.frame = CGRect(x: 0, y: UIScreen.main.bounds.height - self!.frame.height, width: self!.frame.width, height: self!.frame.height)
-        }) { isFinished in
-            if completion != nil {
-                completion!(isFinished)
-            }
-        }
-    }
-
-    /// 动画隐藏view
-    /// - Returns: <#description#>
-    func dismissViewAnimate(duration: TimeInterval = 0.3, completion: ((Bool) -> Void)? = nil) {
-        UIView.animate(withDuration: duration, animations: { [weak self] in
-            self?.frame = CGRect(x: 0, y: UIScreen.main.bounds.height, width: self!.frame.width, height: self!.frame.height)
-        }) { isFinished in
-            if completion != nil {
-                completion!(isFinished)
-            }
-        }
-    }
-
-    /// add  by ak 添加虚线框
-    /// - Parameter color: 框色
-    /// - Parameter lineWidth: 框宽
-    func addBorderToLayer(color: CGColor, lineWidth: CGFloat) {
-        let border = CAShapeLayer()
-
-        //  线条颜色
-        border.strokeColor = color
-        border.fillColor = nil
-
-        border.path = UIBezierPath(rect: bounds).cgPath
-
-        border.frame = bounds
-        border.lineWidth = lineWidth
-        border.lineCap = .square
-
-        //  第一位是 线条长度   第二位是间距 nil时为实线
-        border.lineDashPattern = [9, 4]
-        layer.addSublayer(border)
-    }
-}
-
-// MARK: - UICollectionView的分类扩展
-
-/// UICollectionView的分类扩展
-public extension UICollectionView {
-    /// 获取当前cell
-    /// - Returns: <#description#>
-    func visibleCell() -> UICollectionViewCell? {
-        let visibleRect = CGRect(origin: contentOffset, size: bounds.size)
-        let visiblePoint = CGPoint(x: visibleRect.midX, y: visibleRect.midY)
-        guard let visibleIndexPath = indexPathForItem(at: visiblePoint) else { return nil }
-        return cellForItem(at: visibleIndexPath)
-    }
-
-    func indexPathsForElements(in rect: CGRect) -> [IndexPath] {
-        let allLayoutAttributes = collectionViewLayout.layoutAttributesForElements(in: rect)!
-        return allLayoutAttributes.map { $0.indexPath }
-    }
-}
-
-// MARK: - UITabBar的分类扩展
-
-/// UITabBar的分类扩展
-public extension UITabBar {
-    /// 展示小红点
-    /// - Parameter index: <#index description#>
-    /// - Returns: <#description#>
-    func showPoint(index: Int) {
-        let pointW: CGFloat = 8
-        let pointView = UIView()
-        pointView.tag = 11111 + index
-        pointView.layer.cornerRadius = pointW / 2
-        pointView.backgroundColor = UIColor.hexColor(hexadecimal: "#EE0051")
-        let percentX: CGFloat = CGFloat(Double(index) + 0.7) / CGFloat(items?.count ?? 1)
-        let pointX = ceil(percentX * frame.width)
-        let pointY = ceil(0.1 * frame.height)
-        pointView.frame = CGRect(x: pointX, y: pointY, width: pointW, height: pointW)
-        addSubview(pointView)
-    }
-
-    /// 移除小红点
-    /// - Parameter index: <#index description#>
-    /// - Returns: <#description#>
-    func removePoint(index: Int) {
-        for item in subviews {
-            if item.tag == 11111 + index {
-                item.removeFromSuperview()
-            }
-        }
-    }
-}
-
-// MARK: - UILabel的分类扩展
-
-/// UILabel的分类扩展
-extension UILabel {
-    var isTruncated: Bool {
-        guard let labelText = text else {
-            return false
-        }
-
-        // 计算理论上显示所有文字需要的尺寸
-        let rect = CGSize(width: bounds.width, height: CGFloat.greatestFiniteMagnitude)
-        let labelTextSize = (labelText as NSString)
-            .boundingRect(with: rect, options: .usesLineFragmentOrigin,
-                          attributes: [NSAttributedString.Key.font: font as Any], context: nil)
-
-        // 计算理论上需要的行数
-        let labelTextLines = Int(ceil(CGFloat(labelTextSize.height) / font.lineHeight))
-
-        // 实际可显示的行数
-        var labelShowLines = Int(floor(CGFloat(bounds.size.height) / font.lineHeight))
-        if numberOfLines != 0 {
-            labelShowLines = min(labelShowLines, numberOfLines)
-        }
-
-        // 比较两个行数来判断是否需要截断
-        return labelTextLines > labelShowLines
-    }
-
-    /// 添加阴影
-    /// - Parameters:
-    ///   - color: <#color description#>
-    ///   - offset: <#offset description#>
-    /// - Returns: <#description#>
-    public func addShadow(color: UIColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5), offset: CGSize = CGSize(width: 1, height: 1)) {
-        shadowColor = color
-        shadowOffset = offset
-    }
-}
-
-public extension UIImageView {
-    /// imageView加载网络图片
-    /// - Parameters:
-    ///   - url: 网络url
-    func setNetImage(url: String?, placeholder: UIImage = UIImage.moduleImage(named: "placehold_image", moduleName: "BFCommonKit") ?? UIImage()) {
-        if url == nil || (url?.count ?? 0) <= 0 {
-            return
-        }
-        kf.setImage(with: URL(string: url!), placeholder: placeholder, options: url?.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
-
-        }) { _ in
-        }
-    }
-
-    /// 展示加载中动画
-    /// - Returns: <#description#>
-    func showLoadingAnimation(duration: Double = 1) {
-        let rotationAnim = CABasicAnimation(keyPath: "transform.rotation.z")
-        rotationAnim.fromValue = 0
-        rotationAnim.toValue = Double.pi * 2
-        rotationAnim.repeatCount = MAXFLOAT
-        rotationAnim.duration = duration
-        rotationAnim.isRemovedOnCompletion = false
-        layer.add(rotationAnim, forKey: nil)
-    }
-
-    /// 播放GIF
-    /// - Parameters:
-    ///   - data : 图片二进制数据
-    ///   - images: 图片
-    ///   - repeatCount: 循环次数
-    ///   - duration: 时长
-    /// - Returns: <#description#>
-    func displayGIF(data: Data? = nil, images: [UIImage]? = nil, repeatCount: Int = Int.max, duration: Double = 1) {
-        if images != nil, (images?.count ?? 0) > 0, !isAnimating {
-            layer.removeAllAnimations()
-            stopAnimating()
-            animationImages = images
-            animationDuration = duration
-            animationRepeatCount = repeatCount
-            startAnimating()
-        } else if images == nil && data != nil {
-//            PQPHAssetVideoParaseUtil.parasGIFImage(data: data!) { [weak self] _, images, duration in
-//                if images != nil, (images?.count ?? 0) > 0 {
-//                    self?.displayGIF(images: images!, repeatCount: repeatCount, duration: duration ?? 1)
-//                }
-//            }
-        }
-    }
-
-    /// 移除
-    func removePlayGIF() {
-        layer.removeAllAnimations()
-        stopAnimating()
-    }
-}
-
-public extension UIButton {
-    /// UIButton加载网络图片
-    /// - Parameters:
-    ///   - url: 网络url
-    func setNetImage(url: String?, placeholder: UIImage = UIImage.moduleImage(named: "placehold_image", moduleName: "BFCommonKit") ?? UIImage()) {
-        if url == nil || (url?.count ?? 0) <= 0 {
-//            BFLog(message: "设置按钮网络图片地址为空")
-            return
-        }
-        kf.setImage(with: URL(string: url!), for: .normal, placeholder: placeholder, options: url?.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
-
-        }) { _ in
-        }
-    }
-
-    /// UIButton加载网络背景图片
-    /// - Parameters:
-    ///   - url: 网络url
-    func setNetBackgroundImage(url: String, placeholder: UIImage = UIImage.moduleImage(named: "placehold_image", moduleName: "BFCommonKit") ?? UIImage()) {
-        kf.setBackgroundImage(with: URL(string: url), for: .normal, placeholder: placeholder, options: url.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
-
-        }) { _ in
-        }
-    }
-}

+ 0 - 389
BFCommonKit/Classes/BFCategorys/NXUI+Ext.swift

@@ -1,389 +0,0 @@
-//
-//  NXUI+Ext.swift
-//  NXFramework-Swift-Demo
-//
-//  Created by ak on 2020/10/26.
-//  Copyright © 2020 NXFramework-Swift. All rights reserved.
-//
-
-import UIKit
-
-public extension UIViewController {
-    func showAlert(withTitle title: String?, message: String?) {
-        let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
-        let action = UIAlertAction(title: "OK", style: .cancel, handler: nil)
-        alert.addAction(action)
-
-        present(alert, animated: true, completion: nil)
-    }
-
-    var contentViewController: UIViewController {
-        if let navcon = self as? UINavigationController {
-            return navcon.visibleViewController ?? self
-        } else {
-            return self
-        }
-    }
-}
-
-// Shake oritention
-public enum ShakeDirection: Int {
-    case horizontal
-    case vertical
-}
-
-public extension UIView {
-    func shake(direction: ShakeDirection = .horizontal, times: Int = 5,
-               interval: TimeInterval = 0.1, delta: CGFloat = 2,
-               completion: (() -> Void)? = nil)
-    {
-        UIView.animate(withDuration: interval, animations: { () -> Void in
-            switch direction {
-            case .horizontal:
-                self.layer.setAffineTransform(CGAffineTransform(translationX: delta, y: 0))
-            case .vertical:
-                self.layer.setAffineTransform(CGAffineTransform(translationX: 0, y: delta))
-            }
-        }) { (_) -> Void in
-            if times == 0 {
-                // last shaking finish, reset location, callback
-                UIView.animate(withDuration: interval, animations: { () -> Void in
-                    self.layer.setAffineTransform(CGAffineTransform.identity)
-                }, completion: { (_) -> Void in
-                    completion?()
-                })
-            } else {
-                // not last shaking, continue
-                self.shake(direction: direction, times: times - 1, interval: interval,
-                           delta: delta * -1, completion: completion)
-            }
-        }
-    }
-}
-
-extension UIView {
-    var x: CGFloat {
-        set {
-            var frame = self.frame
-            frame.origin.x = newValue
-            self.frame = frame
-        }
-        get {
-            return frame.origin.x
-        }
-    }
-
-    var y: CGFloat {
-        set {
-            var frame = self.frame
-            frame.origin.y = newValue
-            self.frame = frame
-        }
-        get {
-            return frame.origin.y
-        }
-    }
-
-    var centerX: CGFloat {
-        set {
-            var center = self.center
-            center.x = newValue
-            self.center = center
-        }
-        get {
-            return center.x
-        }
-    }
-
-    var centerY: CGFloat {
-        set {
-            var center = self.center
-            center.y = newValue
-            self.center = center
-        }
-        get {
-            return center.y
-        }
-    }
-
-    var width: CGFloat {
-        set {
-            var frame = self.frame
-            frame.size.width = newValue
-            self.frame = frame
-        }
-        get {
-            return frame.size.width
-        }
-    }
-
-    var height: CGFloat {
-        set {
-            var frame = self.frame
-            frame.size.height = newValue
-            self.frame = frame
-        }
-        get {
-            return frame.size.height
-        }
-    }
-
-    var size: CGSize {
-        set {
-            var frame = self.frame
-            frame.size = newValue
-            self.frame = frame
-        }
-        get {
-            return frame.size
-        }
-    }
-
-    var origin: CGPoint {
-        set {
-            var frame = self.frame
-            frame.origin = newValue
-            self.frame = frame
-        }
-        get {
-            return frame.origin
-        }
-    }
-
-    var bottomY: CGFloat {
-        set {
-            var frame = self.frame
-            frame.origin.y = newValue - frame.size.height
-            self.frame = frame
-        }
-        get {
-            return height + y
-        }
-    }
-
-    var rightX: CGFloat {
-        set {
-            var frame = self.frame
-            frame.origin.x = newValue - frame.size.width
-            self.frame = frame
-        }
-        get {
-            return width + x
-        }
-    }
-
-    // MARK: - UIView round corner
-
-    ///
-    /// - Parameter cornerRadius: radius
-    func roundedCorners(cornerRadius: CGFloat) {
-        roundedCorners(cornerRadius: cornerRadius, borderWidth: 0, borderColor: nil)
-    }
-
-    ///
-    /// - Parameters:
-    ///   - cornerRadius:
-    ///   - borderWidth:
-    ///   - borderColor:
-    func roundedCorners(cornerRadius: CGFloat?, borderWidth: CGFloat?, borderColor: UIColor?) {
-        layer.cornerRadius = cornerRadius!
-        layer.borderWidth = borderWidth!
-        layer.borderColor = borderColor?.cgColor
-        layer.masksToBounds = true
-    }
-
-    ///
-    /// - Parameters:
-    ///   - cornerRadius:
-    ///   - rectCorner:
-    func roundedCorners(cornerRadius: CGFloat?, rectCorner: UIRectCorner?) {
-        let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: rectCorner!, cornerRadii: CGSize(width: cornerRadius!, height: cornerRadius!))
-        let layer = CAShapeLayer()
-        layer.frame = bounds
-        layer.path = path.cgPath
-        self.layer.mask = layer
-    }
-
-    ///
-    /// - Parameters:
-    ///   - colors:
-    ///   - locations:
-    ///   - startPoint: [0...1]
-    ///   - endPoint: [0...1]
-    func gradientColor(colors: [CGColor], locations: [NSNumber], startPoint: CGPoint, endPoint: CGPoint) {
-        let gradientLayer = CAGradientLayer()
-        gradientLayer.colors = colors
-        gradientLayer.locations = locations
-        /*
-         // vertical
-         gradientLayer.startPoint = CGPoint(x: 0, y: 0)
-         gradientLayer.endPoint = CGPoint(x: 0, y: 1)
-         */
-        gradientLayer.startPoint = startPoint
-        gradientLayer.endPoint = endPoint
-        gradientLayer.frame = frame
-        layer.insertSublayer(gradientLayer, at: 0)
-    }
-
-    // MARK: - UIView blur
-
-    ///
-    /// - Parameter style: UIBlurEffectStyle
-    func addBlurEffect(style _: UIBlurEffect.Style) {
-        let effect = UIBlurEffect(style: UIBlurEffect.Style.light)
-        let effectView = UIVisualEffectView(effect: effect)
-        effectView.frame = bounds
-        backgroundColor = .clear
-        addSubview(effectView)
-        sendSubviewToBack(effectView)
-    }
-}
-
-public extension UIView {
-    /// 往当前视图添加一个子视图
-    /// - Parameters:
-    ///   - rect: 子视图大小
-    ///   - bgColor: 子视图背景色
-    /// - Returns: 子视图
-    func nx_addView(rect: CGRect = .zero, bgColor: UIColor = .white) -> UIView {
-        let view = UIView(frame: rect)
-        view.backgroundColor = bgColor
-        addSubview(view)
-        return view
-    }
-
-    /// 往当前视图添加UIImageView
-    /// - Parameters:
-    ///   - image: 图片对象
-    ///   - rect: UIImageView
-    ///   - contentMode: 图片填充模式
-    /// - Returns: 图片
-    func nx_addImageView(image: UIImage?, rect: CGRect = .zero, contentMode: ContentMode = .scaleAspectFit) -> UIImageView {
-        let imageView = UIImageView(frame: rect)
-        imageView.image = image
-        imageView.contentMode = contentMode
-        addSubview(imageView)
-        return imageView
-    }
-
-    /// 添加文本控件
-    /// - Parameters:
-    ///   - fontSize: 文本大小
-    ///   - text: 文本
-    ///   - textColor: 文本颜色
-    ///   - bgColor: 背景颜色
-    /// - Returns: 文本控件
-    func nx_addLabel(fontSize: CGFloat, text: String, textColor: UIColor, bgColor: UIColor) -> UILabel {
-        return nx_addLabel(font: UIFont.systemFont(ofSize: fontSize),
-                           text: text,
-                           textColor: textColor,
-                           bgColor: bgColor)
-    }
-
-    /// 添加文本控件
-    /// - Parameters:
-    ///   - font: 文本大小
-    ///   - text: 文本
-    ///   - textColor: 文本颜色
-    ///   - bgColor: 背景颜色
-    /// - Returns: 文本控件
-    func nx_addLabel(font: UIFont, text: String, textColor: UIColor, bgColor: UIColor) -> UILabel {
-        let label = UILabel(frame: .zero)
-        label.font = font
-        label.text = text
-        label.textColor = textColor
-        label.backgroundColor = bgColor
-        addSubview(label)
-        return label
-    }
-
-    /// 添加按钮控件
-    /// - Parameters:
-    ///   - rect: 控件大小
-    ///   - title: 标题
-    ///   - titleColor: 标题颜色
-    ///   - font: 字体
-    ///   - image: 图片
-    ///   - bgImg: 背景图片
-    ///   - target: 事件响应者
-    ///   - action: 事件响应方法
-    ///   - event: 响应事件
-    /// - Returns: 按钮
-    func nx_addButton(rect: CGRect, title: String, titleColor: UIColor, font: UIFont, image: UIImage?, bgImg: UIImage?, target: Any?, action: Selector?, event: UIControl.Event?) -> UIButton {
-        let btn = UIButton(type: .custom)
-        btn.frame = rect
-        btn.setTitle(title, for: .normal)
-        btn.setTitle(title, for: .highlighted)
-        btn.setTitleColor(titleColor, for: .normal)
-        btn.setTitleColor(titleColor, for: .highlighted)
-        btn.setImage(image, for: .normal)
-        btn.setImage(image, for: .highlighted)
-        btn.setBackgroundImage(bgImg, for: .normal)
-        btn.setBackgroundImage(bgImg, for: .highlighted)
-        btn.titleLabel?.font = font
-        if let sel = action, let e = event {
-            btn.addTarget(target, action: sel, for: e)
-        }
-        addSubview(btn)
-        return btn
-    }
-
-    /// 添加一个文本类型的按钮控件
-    /// - Parameters:
-    ///   - rect: 按钮大小
-    ///   - title: 文本
-    ///   - titleColor: 文本颜色
-    ///   - target: 事件响应者
-    ///   - action: 事件响应方法
-    ///   - event:响应事件
-    /// - Returns: 按钮控件
-    func nx_addButton(rect: CGRect, title: String, titleColor: UIColor, target: Any?, action: Selector?, event: UIControl.Event?) -> UIButton {
-        return nx_addButton(rect: rect,
-                            title: title,
-                            titleColor: titleColor,
-                            font: UIFont.systemFont(ofSize: 14),
-                            image: nil,
-                            bgImg: nil,
-                            target: target,
-                            action: action,
-                            event: event)
-    }
-
-    /// 添加图片类型按钮
-    /// - Parameters:
-    ///   - rect: 按钮大小
-    ///   - image: 图片
-    ///   - target: 事件响应者
-    ///   - action: 事件响应方法
-    ///   - event: 响应事件
-    /// - Returns: 按钮控件
-    func nx_addButton(rect: CGRect, image: UIImage, target: Any?, action: Selector?, event: UIControl.Event?) -> UIButton {
-        return nx_addButton(rect: rect,
-                            title: "",
-                            titleColor: .white,
-                            font: UIFont.systemFont(ofSize: 14),
-                            image: image,
-                            bgImg: nil,
-                            target: target,
-                            action: action,
-                            event: event)
-    }
-
-    /// 添加tableView
-    /// - Parameters:
-    ///   - rect: 大小
-    ///   - delegate: delegate对象
-    ///   - dataSource: dataSource 对象
-    /// - Returns: 表视图
-    func nx_addTableView(rect: CGRect, delegate: UITableViewDelegate?, dataSource: UITableViewDataSource?) -> UITableView {
-        let tableView = UITableView(frame: rect)
-        tableView.delegate = delegate
-        tableView.dataSource = dataSource
-        backgroundColor = .white
-        tableView.tableFooterView = UIView()
-        if #available(iOS 11.0, *) {
-            tableView.contentInsetAdjustmentBehavior = .never
-        }
-        return tableView
-    }
-}

+ 0 - 32
BFCommonKit/Classes/BFCategorys/UIControl+NXCategory.h

@@ -1,32 +0,0 @@
-//
-//  UIControl+acceptEventInterval.h
-//  NXlib
-//
-//  Created by AK on 15/9/15.
-//  Copyright (c) 2015年 AK. All rights reserved.
-//
-
-// 本类的作用
-// 防止多次连续点击事件,加一个两次点击的时间间隔,专治各种测试人员-_-!
-// 使用 addTarget:action:forControlEvents 给对象添加事件的都可以加时间间隔 如
-// UIButton、UISwitch、UITextField
-
-/*
- *	UIButton * testBtn;
- *  testBtn.uxy_acceptEventInterval = 2.5;
- */
-#import <UIKit/UIKit.h>
-
-@interface UIControl (NXCategory)
-
-/**
- *  设置重复点击加间隔。
- */
-@property(nonatomic, assign) NSTimeInterval uxy_acceptEventInterval;
-
-/**
- *  忽略本次点击。
- */
-@property(nonatomic) BOOL ignoreEvent;
-
-@end

+ 0 - 68
BFCommonKit/Classes/BFCategorys/UIControl+NXCategory.m

@@ -1,68 +0,0 @@
-//
-//  UIControl+acceptEventInterval.m
-//  NXlib
-//
-//  Created by AK on 15/9/15.
-//  Copyright (c) 2015年 AK. All rights reserved.
-//
-
-#import "UIControl+NXCategory.h"
-
-#if TARGET_OS_IPHONE
-#import <objc/message.h>
-#import <objc/runtime.h>
-#else
-#import <objc/objc-class.h>
-#endif
-
-@implementation UIControl (NXCategory)
-
-static const char *UIControl_acceptEventInterval = "UIControl_acceptEventInterval";
-static const char *UIControl_ignoreEvent = "UIControl_ignoreEvent";
-
-//改变两个方法的实现。在类第一次使用的时候回调用这个方法
-+ (void)load
-{
-    Method a = class_getInstanceMethod(self, @selector(sendAction:to:forEvent:));
-    Method b = class_getInstanceMethod(self, @selector(__uxy_sendAction:to:forEvent:));
-    //改变两个方法的实现
-    method_exchangeImplementations(a, b);  // isnt
-}
-//通过关联对象重写get和set方法
-- (NSTimeInterval)uxy_acceptEventInterval
-{
-    return [objc_getAssociatedObject(self, UIControl_acceptEventInterval) doubleValue];
-}
-
-- (void)setUxy_acceptEventInterval:(NSTimeInterval)uxy_acceptEventInterval
-{
-    objc_setAssociatedObject(self, UIControl_acceptEventInterval, @(uxy_acceptEventInterval),
-                             OBJC_ASSOCIATION_RETAIN_NONATOMIC);
-}
-#pragma mark 现在是否可点的get和set。通过关联对象。
-- (void)setIgnoreEvent:(BOOL)ignoreEvent
-{
-    objc_setAssociatedObject(self, UIControl_ignoreEvent, @(ignoreEvent), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
-}
-- (BOOL)ignoreEvent { return [objc_getAssociatedObject(self, UIControl_ignoreEvent) boolValue]; }
-- (void)__uxy_sendAction:(SEL)action to:(id)target forEvent:(UIEvent *)event
-{
-    if (self.ignoreEvent)
-    {
-        NSLog(@"无效点击!!!!!!!!!!");
-        return;
-    }
-    if (self.uxy_acceptEventInterval > 0)
-    {
-        self.ignoreEvent = YES;
-        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(self.uxy_acceptEventInterval * NSEC_PER_SEC)),
-                       dispatch_get_main_queue(), ^{
-                           self.ignoreEvent = NO;
-                       });
-    }
-
-    //调用系统实现
-    [self __uxy_sendAction:action to:target forEvent:event];
-}
-
-@end

+ 0 - 201
BFCommonKit/Classes/BFCategorys/UIImage+NXCategory.h

@@ -1,201 +0,0 @@
-//
-//  UIImage+UIImage_NXCategory.h
-//  AKImovie
-//
-//  Created by AK on 16/2/21.
-//  Copyright © 2016年 ak. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-typedef NS_ENUM(NSInteger, NXCropImageStyle) {
-    NXCropImageStyleRight = 0,               // 右半部分
-    NXCropImageStyleCenter = 1,              // 中间部分
-    NXCropImageStyleLeft = 2,                // 左半部分
-    NXCropImageStyleRightOneOfThird = 3,     // 右侧三分之一部分
-    NXCropImageStyleCenterOneOfThird = 4,    // 中间三分之一部分
-    NXCropImageStyleLeftOneOfThird = 5,      // 左侧三分之一部分
-    NXCropImageStyleRightQuarter = 6,        // 右侧四分之一部分
-    NXCropImageStyleCenterRightQuarter = 7,  // 中间右侧四分之一部分
-    NXCropImageStyleCenterLeftQuarter = 8,   // 中间左侧四分之一部分
-    NXCropImageStyleLeftQuarter = 9,         // 左侧四分之一部分
-};
-
-@interface UIImage (NXCategory)
-
-#pragma mark - blur 效果
-/**
- 给图片打马赛克
- @param image 原始图片
- @param blur 值越 blurry 就越大
- @return 处理后的图片
- */
-+ (UIImage *)nx_blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur;
-
-/**
-  boxblur image 这个要在整理
-
-  @param toBlurImage 要处理的图片
-  @return 处理后图片
- */
-+ (UIImage *)nx_boxblurImage:(UIImage *)toBlurImage;
-
-#pragma mark - 旋转
-/**
-  照片旋转90度,如从系统相册中取出的原图要转正
-
- @param aImage 原图
- @param isFront YES 为前置拍照
- @return 转正后图片
- */
-+ (UIImage *)nx_fixOrientation:(UIImage *)aImage isFront:(BOOL)isFront;
-
-/**
- 旋转图片
-
- @param image 原图
- @param orientation 旋转的方向
- @return 旋转后的图片
- */
-+ (UIImage *)nx_rotationImage:(UIImage *)image orientation:(UIImageOrientation)orientation;
-
-#pragma mark - 缩放
-/**
- 等比缩放图片
-
- @param size 放到的大小(单位为像素)
- @return 处理后的图片
- */
-- (UIImage *)nx_scaleToSize:(CGSize)size;
-
-/**
- 等比缩放图片 按照最短边缩放
- @param maxLength 边长最大值 (单位为像素)
- @return 处理后的图片
- */
-- (UIImage *)nx_scaleWithMaxLength:(float)maxLength;
-
-#pragma mark - 截取
-/**
- 截取 uiimage 指定区域
-
- @param style 类型为 NXCropImageStyle
- @return 裁剪后的图片
- */
-- (UIImage *)nx_imageByCroppingWithStyle:(NXCropImageStyle)style;
-
-/**
-  截取 uiimage 指定区域
-
- @param rect 裁剪区域
- @return 裁剪后的图片
- */
-- (UIImage *)imageByCroppingWithRect:(CGRect)rect;
-
-
-/**
- 将图片按照最短边等比截取图片中间部分
-
- @return 截取后到正方形图片
- */
-- (UIImage *)nx_cropImageToSquare;
-
-/**
- *  将图片等比绘制到正方形画布中并重新生成新图
- *
- *  @return 处理后的图片
- */
-- (UIImage *)nx_zoomImageToSquare;
-
-/**
- 将图片等比缩放的指定的画布中并生成新图。(跟画布比例不一样的做 左右或者上下留白处理)
-
- @param size 指定画布大小
- @return 处理后的新图
- */
-- (UIImage *)nx_zoomWithSize:(CGSize)size;
-
-/**
- 高清截屏 opaque 为no 有透明度速度会慢一些
-
- @param view 指定的VIEW
- @return 截屏图片
- */
-+ (UIImage *)nx_screenHierarchyShots:(UIView *)view;
-
-/**
- 高清截屏
-
- @param view 指定的VIEW
- @param opaque 透明开关,如果图形完全不用透明,设置为YES以优化位图的存储。
- @return 截屏图片
- */
-+ (UIImage *)nx_screenHierarchyShots:(UIView *)view isOpaque:(BOOL)opaque;
-
-/**
- 获得裁剪图片
-
- e.g.
- int squalWidth = MIN(self.clipImage.size.width, self.clipImage.size.height);
-
- float clipX = _clipScroll.contentOffset.x;
- float clipY = _clipScroll.contentOffset.y;
- CGRect rect = CGRectMake(clipX, clipY, NX_MAIN_SCREEN_WIDTH, NX_MAIN_SCREEN_WIDTH);
-
- clipedImage =
- [UIImage nx_cropImageView:_bigImageView toRect:rect zoomScale:1
- containerView:_backView outputWith:squalWidth];
-
- @param imageView 原始VIEW
- @param rect 截取区域
- @param zoomScale 缩放大小
- @param containerView 显示区域VIEW
- @param outputWith 输出大小
- @return 处理后图片
- */
-+ (UIImage *)nx_cropImageView:(UIImageView *)imageView
-                       toRect:(CGRect)rect
-                    zoomScale:(double)zoomScale
-                containerView:(UIView *)containerView
-                   outputWith:(CGFloat)outputWith;
-
-#pragma mark - 圆角
-/**
- 切圆角 可防止离屏渲染
- e.g.
- UIImage *placeHolder = [[UIImage imageNamed:@"userIcon"] circleImage];
-
- @param img 原图片
- @return 处理后的图片
- */
-+ (UIImage *)nx_circleImage:(UIImage *)img;
-
-/** 切圆角 可防止离屏渲染
- * @param image 需要进行圆角的图片
- * @param direction 切割的方向
- * @param cornerRadii 圆角半径
- * @param borderWidth 边框宽度
- * @param borderColor 边框颜色
- * @param backgroundColor 背景色
- * @return 处理后的图片
- */
-+ (UIImage *)nx_circleImage:(UIImage *)image cuttingDirection:(UIRectCorner)direction cornerRadii:(CGFloat)cornerRadii borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor backgroundColor:(UIColor *)backgroundColor;
-
-/**
- 获取当前屏幕大小的的开屏页图片
- 
- @return 开屏页图片
- */
-+ (UIImage *)nx_launchImage;
-
-
-/**
- 把指定颜色背景变成透明
-
- @param image 原图数据
- @param color 原背景色
- @return 背景透明后的图
- */
-+ (UIImage*)transparentBackClear:(UIImage*)image color:(UIColor*)color;
-
-@end

+ 0 - 642
BFCommonKit/Classes/BFCategorys/UIImage+NXCategory.m

@@ -1,642 +0,0 @@
-//
-//  UIImage+UIImage_NXCategory.m
-//  AKImovie
-//
-//  Created by AK on 16/2/21.
-//  Copyright © 2016年 ak. All rights reserved.
-//
-
-#import "UIImage+NXCategory.h"
-#import <Accelerate/Accelerate.h>
-
-@implementation UIImage (NXCategory)
-
-#pragma mark - blur 效果
-+ (UIImage *)nx_blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur
-{
-    CIImage *inputImage = [CIImage imageWithCGImage:image.CGImage];
-    CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"
-                                  keysAndValues:kCIInputImageKey, inputImage, @"inputRadius", @(blur), nil];
-
-    CIImage *outputImage = filter.outputImage;
-    CIContext *context = [CIContext contextWithOptions:nil];
-    CGImageRef outImage = [context createCGImage:outputImage fromRect:[outputImage extent]];
-    return [UIImage imageWithCGImage:outImage];
-}
-
-+ (UIImage *)nx_boxblurImage:(UIImage *)toBlurImage
-{
-    UIImage *newImage =
-
-        [toBlurImage nx_scaleToSize:CGSizeMake(toBlurImage.size.width / 2., toBlurImage.size.height / 2.)];
-
-    NSData *jpgData = UIImageJPEGRepresentation(newImage, 0.01);
-
-    UIImage *image = [UIImage imageWithData:jpgData];
-    CGFloat blur = 0.3f;
-
-    int boxSize = (int)(blur * 40);
-    boxSize = boxSize - (boxSize % 2) + 1;
-
-    CGImageRef img = image.CGImage;
-    vImage_Buffer inBuffer, outBuffer;
-    vImage_Error error;
-    void *pixelBuffer;
-
-    // create vImage_Buffer with data from CGImageRef
-    CGDataProviderRef inProvider = CGImageGetDataProvider(img);
-    CFDataRef inBitmapData = CGDataProviderCopyData(inProvider);
-
-    inBuffer.width = CGImageGetWidth(img);
-    inBuffer.height = CGImageGetHeight(img);
-    inBuffer.rowBytes = CGImageGetBytesPerRow(img);
-
-    inBuffer.data = (void *)CFDataGetBytePtr(inBitmapData);
-
-    // create vImage_Buffer for output
-    pixelBuffer = malloc(CGImageGetBytesPerRow(img) * CGImageGetHeight(img));
-
-    if (pixelBuffer == NULL) NSLog(@"No pixelbuffer");
-
-    outBuffer.data = pixelBuffer;
-    outBuffer.width = CGImageGetWidth(img);
-    outBuffer.height = CGImageGetHeight(img);
-    outBuffer.rowBytes = CGImageGetBytesPerRow(img);
-
-    // perform convolution
-    error =
-        vImageBoxConvolve_ARGB8888(&inBuffer, &outBuffer, NULL, 0, 0, boxSize, boxSize, NULL, kvImageEdgeExtend)
-            ?: vImageBoxConvolve_ARGB8888(&outBuffer, &inBuffer, NULL, 0, 0, boxSize, boxSize, NULL, kvImageEdgeExtend)
-                   ?: vImageBoxConvolve_ARGB8888(&inBuffer, &outBuffer, NULL, 0, 0, boxSize, boxSize, NULL,
-                                                 kvImageEdgeExtend);
-
-    if (error)
-    {
-        NSLog(@"error from convolution %ld", error);
-    }
-
-    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-    CGContextRef ctx = CGBitmapContextCreate(outBuffer.data, outBuffer.width, outBuffer.height, 8, outBuffer.rowBytes,
-                                             colorSpace, (CGBitmapInfo)kCGImageAlphaNoneSkipLast);
-    CGImageRef imageRef = CGBitmapContextCreateImage(ctx);
-    UIImage *returnImage = [UIImage imageWithCGImage:imageRef];
-
-    // clean up
-    CGContextRelease(ctx);
-    CGColorSpaceRelease(colorSpace);
-
-    free(pixelBuffer);
-    CFRelease(inBitmapData);
-    CGImageRelease(imageRef);
-
-    return returnImage;
-}
-
-#pragma mark - 旋转
-+ (UIImage *)nx_fixOrientation:(UIImage *)aImage isFront:(BOOL)isFront;
-{
-    // No-op if the orientation is already correct
-    if (aImage.imageOrientation == UIImageOrientationUp) return aImage;
-
-    // We need to calculate the proper transformation to make the image upright.
-    // We do it in 2 steps: Rotate if Left/Right/Down, and then flip if Mirrored.
-    CGAffineTransform transform = CGAffineTransformIdentity;
-
-    if (isFront)
-    {
-        transform = CGAffineTransformTranslate(transform, aImage.size.width, 0);
-        transform = CGAffineTransformScale(transform, -1, 1);
-    }
-
-    switch (aImage.imageOrientation)
-    {
-        case UIImageOrientationDown:
-        case UIImageOrientationDownMirrored:
-            transform = CGAffineTransformTranslate(transform, aImage.size.width, aImage.size.height);
-            transform = CGAffineTransformRotate(transform, M_PI);
-            break;
-
-        case UIImageOrientationLeft:
-        case UIImageOrientationLeftMirrored:
-            transform = CGAffineTransformTranslate(transform, aImage.size.width, 0);
-            transform = CGAffineTransformRotate(transform, M_PI_2);
-            break;
-
-        case UIImageOrientationRight:
-        case UIImageOrientationRightMirrored:
-            transform = CGAffineTransformTranslate(transform, 0, aImage.size.height);
-            transform = CGAffineTransformRotate(transform, -M_PI_2);
-            break;
-        default:
-            break;
-    }
-
-    switch (aImage.imageOrientation)
-    {
-        case UIImageOrientationUpMirrored:
-        case UIImageOrientationDownMirrored:
-            transform = CGAffineTransformTranslate(transform, aImage.size.width, 0);
-            transform = CGAffineTransformScale(transform, -1, 1);
-            break;
-
-        case UIImageOrientationLeftMirrored:
-        case UIImageOrientationRightMirrored:
-            transform = CGAffineTransformTranslate(transform, aImage.size.height, 0);
-            transform = CGAffineTransformScale(transform, -1, 1);
-            break;
-        default:
-            break;
-    }
-
-    // Now we draw the underlying CGImage into a new context, applying the
-    // transform
-    // calculated above.
-    CGContextRef ctx =
-        CGBitmapContextCreate(NULL, aImage.size.width, aImage.size.height, CGImageGetBitsPerComponent(aImage.CGImage),
-                              0, CGImageGetColorSpace(aImage.CGImage), CGImageGetBitmapInfo(aImage.CGImage));
-    CGContextConcatCTM(ctx, transform);
-    switch (aImage.imageOrientation)
-    {
-        case UIImageOrientationLeft:
-        case UIImageOrientationLeftMirrored:
-        case UIImageOrientationRight:
-        case UIImageOrientationRightMirrored:
-            // Grr...
-            CGContextDrawImage(ctx, CGRectMake(0, 0, aImage.size.height, aImage.size.width), aImage.CGImage);
-            break;
-
-        default:
-            CGContextDrawImage(ctx, CGRectMake(0, 0, aImage.size.width, aImage.size.height), aImage.CGImage);
-            break;
-    }
-
-    // And now we just create a new UIImage from the drawing context
-    CGImageRef cgimg = CGBitmapContextCreateImage(ctx);
-    UIImage *img = [UIImage imageWithCGImage:cgimg];
-    CGContextRelease(ctx);
-    CGImageRelease(cgimg);
-    return img;
-}
-
-// 旋转
-+ (UIImage *)nx_rotationImage:(UIImage *)image orientation:(UIImageOrientation)orientation
-{
-    long double rotate = 0.0;
-    CGRect rect;
-    float translateX = 0;
-    float translateY = 0;
-    float scaleX = 1.0;
-    float scaleY = 1.0;
-
-    switch (orientation)
-    {
-        case UIImageOrientationLeft:
-            rotate = M_PI_2;
-            rect = CGRectMake(0, 0, image.size.height, image.size.width);
-            translateX = 0;
-            translateY = -rect.size.width;
-            scaleY = rect.size.width / rect.size.height;
-            scaleX = rect.size.height / rect.size.width;
-            break;
-        case UIImageOrientationRight:
-            rotate = 3 * M_PI_2;
-            rect = CGRectMake(0, 0, image.size.height, image.size.width);
-            translateX = -rect.size.height;
-            translateY = 0;
-            scaleY = rect.size.width / rect.size.height;
-            scaleX = rect.size.height / rect.size.width;
-            break;
-        case UIImageOrientationDown:
-            rotate = M_PI;
-            rect = CGRectMake(0, 0, image.size.width, image.size.height);
-            translateX = -rect.size.width;
-            translateY = -rect.size.height;
-            break;
-        default:
-            rotate = 0.0;
-            rect = CGRectMake(0, 0, image.size.width, image.size.height);
-            translateX = 0;
-            translateY = 0;
-            break;
-    }
-
-    UIGraphicsBeginImageContext(rect.size);
-    CGContextRef context = UIGraphicsGetCurrentContext();
-    //做CTM变换
-    CGContextTranslateCTM(context, 0.0, rect.size.height);
-    CGContextScaleCTM(context, 1.0, -1.0);
-    CGContextRotateCTM(context, rotate);
-    CGContextTranslateCTM(context, translateX, translateY);
-
-    CGContextScaleCTM(context, scaleX, scaleY);
-    //绘制图片
-    CGContextDrawImage(context, CGRectMake(0, 0, rect.size.width, rect.size.height), image.CGImage);
-
-    UIImage *newPic = UIGraphicsGetImageFromCurrentImageContext();
-    NSLog(@"image size %f---%f", image.size.width, image.size.height);
-    UIGraphicsEndImageContext();
-    return newPic;
-}
-
-#pragma mark - 缩放
-- (UIImage *)nx_scaleToSize:(CGSize)size
-{
-    CGFloat width = CGImageGetWidth(self.CGImage);
-    CGFloat height = CGImageGetHeight(self.CGImage);
-
-    float verticalRadio = size.height * 1.0 / height;
-    float horizontalRadio = size.width * 1.0 / width;
-
-    float radio = 1;
-    if (verticalRadio > 1 && horizontalRadio > 1)
-    {
-        radio = verticalRadio > horizontalRadio ? horizontalRadio : verticalRadio;
-    }
-    else
-    {
-        radio = verticalRadio < horizontalRadio ? verticalRadio : horizontalRadio;
-    }
-
-    width = width * radio;
-    height = height * radio;
-
-    int xPos = (size.width - width) / 2;
-    int yPos = (size.height - height) / 2;
-
-    // 创建一个bitmap的context
-    // 并把它设置成为当前正在使用的context
-    UIGraphicsBeginImageContext(size);
-
-    // 绘制改变大小的图片
-    [self drawInRect:CGRectMake(xPos, yPos, width, height)];
-
-    // 从当前context中创建一个改变大小后的图片
-    UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
-
-    // 使当前的context出堆栈
-    UIGraphicsEndImageContext();
-
-    // 返回新的改变大小后的图片
-    return scaledImage;
-}
-
-//按照最短边缩放 maxlength 边长最大值
-- (UIImage *)nx_scaleWithMaxLength:(float)maxLength
-{
-    if (self.size.width > maxLength || self.size.height > maxLength)
-    {
-        float maxWidth = maxLength;
-        float maxHeight = maxLength;
-
-        if (self.size.width != self.size.height)
-        {
-            if (self.size.width > self.size.height)
-            {
-                //按照宽 来缩放
-                float imageScale = maxLength / self.size.width;
-                maxHeight = self.size.height * imageScale;
-            }
-            else if (self.size.width < self.size.height)
-            {
-                float imageScale = maxLength / self.size.height;
-
-                maxWidth = self.size.width * imageScale;
-            }
-        }
-        // 返回新的改变大小后的图片
-        return [self nx_scaleToSize:CGSizeMake(maxWidth, maxHeight)];
-    }
-
-    return self;
-}
-
-#pragma mark - 截取
-- (UIImage *)nx_imageByCroppingWithStyle:(NXCropImageStyle)style
-{
-    CGRect rect = CGRectZero;
-    switch (style)
-    {
-        case NXCropImageStyleLeft:
-            rect = CGRectMake(0, 0, self.size.width / 2, self.size.height);
-            break;
-        case NXCropImageStyleCenter:
-            rect = CGRectMake(self.size.width / 4, 0, self.size.width / 2, self.size.height);
-            break;
-        case NXCropImageStyleRight:
-            rect = CGRectMake(self.size.width / 2, 0, self.size.width / 2, self.size.height);
-            break;
-        case NXCropImageStyleLeftOneOfThird:
-            rect = CGRectMake(0, 0, self.size.width / 3, self.size.height);
-            break;
-        case NXCropImageStyleCenterOneOfThird:
-            rect = CGRectMake(self.size.width / 3, 0, self.size.width / 3, self.size.height);
-            break;
-        case NXCropImageStyleRightOneOfThird:
-            rect = CGRectMake(self.size.width / 3 * 2, 0, self.size.width / 3, self.size.height);
-            break;
-        case NXCropImageStyleLeftQuarter:
-            rect = CGRectMake(0, 0, self.size.width / 4, self.size.height);
-            break;
-        case NXCropImageStyleCenterLeftQuarter:
-            rect = CGRectMake(self.size.width / 4, 0, self.size.width / 4, self.size.height);
-            break;
-        case NXCropImageStyleCenterRightQuarter:
-            rect = CGRectMake(self.size.width / 4 * 2, 0, self.size.width / 4, self.size.height);
-            break;
-        case NXCropImageStyleRightQuarter:
-            rect = CGRectMake(self.size.width / 4 * 3, 0, self.size.width / 4, self.size.height);
-            break;
-        default:
-            break;
-    }
-
-    return [self imageByCroppingWithRect:rect];
-}
-
-- (UIImage *)imageByCroppingWithRect:(CGRect)rect
-{
-    CGImageRef imageRef = self.CGImage;
-    CGImageRef imagePartRef = CGImageCreateWithImageInRect(imageRef, rect);
-    UIImage *cropImage = [UIImage imageWithCGImage:imagePartRef];
-    CGImageRelease(imagePartRef);
-    return cropImage;
-}
-
-- (UIImage *)nx_cropImageToSquare{
-
-    if(self.size.width == self.size.height)
-    {
-        return self;
-    }
-    double w = self.size.width;
-    double h = self.size.height;
-    double m = MIN(w, h);
-    CGRect rect = CGRectMake((self.size.width - m)/2.0f , (self.size.height - m)/2.0f, m, m);
-    return [self imageByCroppingWithRect:rect];
-}
-
-- (UIImage *)nx_zoomWithSize:(CGSize)size{
-
-    if(self == nil)
-    {
-        return nil;
-    }
-    
-    double w  = self.size.width;
-    double h =self.size.height;
-    double vRatio = w / size.width;
-    double hRatio = h / size.height;
-    double ratio = MAX(vRatio, hRatio);
-    w /= ratio;
-    h /= ratio;
-    CGRect drawRect = CGRectMake((size.width - w)/2.0f , (size.height - h)/2.0f, w, h);
-    // 创建一个bitmap的context
-    // 并把它设置成为当前正在使用的context
-    UIGraphicsBeginImageContext(size);
-    // 绘制改变大小的图片
-    [self drawInRect:drawRect];
-    // 从当前context中创建一个改变大小后的图片
-    UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
-    // 使当前的context出堆栈
-    UIGraphicsEndImageContext();
-    return  scaledImage;
-    
-}
-
-
-- (UIImage *)nx_zoomImageToSquare
-{
-    if (self == nil)
-    {
-        return nil;
-    }
-    double tw = MIN(self.size.width, self.size.height);
-
-    return [self nx_scaleToSize:CGSizeMake(tw, tw)];
-}
-
-//截屏 有透明的
-+ (UIImage *)nx_screenHierarchyShots:(UIView *)view { return [UIImage nx_screenHierarchyShots:view isOpaque:NO]; }
-//高清截屏 opaque 是否有透明图层
-+ (UIImage *)nx_screenHierarchyShots:(UIView *)view isOpaque:(BOOL)opaque
-{
-    // size——同UIGraphicsBeginImageContext
-    // opaque—透明开关,如果图形完全不用透明,设置为YES以优化位图的存储。
-    // scale—–缩放因子
-    UIGraphicsBeginImageContextWithOptions(view.bounds.size, opaque, 0);
-    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
-    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
-    UIGraphicsEndImageContext();
-    return image;
-}
-
-/// 获得裁剪后的图片
-+ (UIImage *)nx_cropImageView:(UIImageView *)imageView
-                       toRect:(CGRect)rect
-                    zoomScale:(double)zoomScale
-                containerView:(UIView *)containerView
-                   outputWith:(CGFloat)outputWith
-{
-    CGAffineTransform transform = CGAffineTransformIdentity;
-    // 平移的处理
-    CGRect imageViewRect = [imageView convertRect:imageView.bounds toView:containerView];
-    CGPoint point = CGPointMake(imageViewRect.origin.x + imageViewRect.size.width / 2,
-                                imageViewRect.origin.y + imageViewRect.size.height / 2);
-
-    CGPoint zeroPoint =
-        CGPointMake(CGRectGetWidth(containerView.frame) / 2., CGRectGetHeight(containerView.frame) / 2.);
-
-    CGPoint translation = CGPointMake(point.x - zeroPoint.x, point.y - zeroPoint.y);
-    transform = CGAffineTransformTranslate(transform, translation.x, translation.y);
-    // 缩放的处理
-    transform = CGAffineTransformScale(transform, zoomScale, zoomScale);
-
-    CGImageRef imageRef = [self nx_newTransformedImage:transform
-                                           sourceImage:imageView.image.CGImage
-                                            sourceSize:imageView.image.size
-                                           outputWidth:outputWith
-                                              cropSize:rect.size
-                                         imageViewSize:imageView.frame.size];
-    UIImage *cropedImage = [UIImage imageWithCGImage:imageRef];
-    CGImageRelease(imageRef);
-    return cropedImage;
-}
-
-+ (CGImageRef)nx_newTransformedImage:(CGAffineTransform)transform
-                         sourceImage:(CGImageRef)sourceImage
-                          sourceSize:(CGSize)sourceSize
-                         outputWidth:(CGFloat)outputWidth
-                            cropSize:(CGSize)cropSize
-                       imageViewSize:(CGSize)imageViewSize
-{
-    CGImageRef source = [self nx_newScaledImage:sourceImage toSize:sourceSize];
-
-    CGFloat aspect = cropSize.height / cropSize.width;
-    CGSize outputSize = CGSizeMake(outputWidth, outputWidth * aspect);
-
-    CGContextRef context =
-        CGBitmapContextCreate(NULL, outputSize.width, outputSize.height, CGImageGetBitsPerComponent(source), 0,
-                              CGImageGetColorSpace(source), CGImageGetBitmapInfo(source));
-    CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
-    CGContextFillRect(context, CGRectMake(0, 0, outputSize.width, outputSize.height));
-
-    CGAffineTransform uiCoords =
-        CGAffineTransformMakeScale(outputSize.width / cropSize.width, outputSize.height / cropSize.height);
-    uiCoords = CGAffineTransformTranslate(uiCoords, cropSize.width / 2.0, cropSize.height / 2.0);
-    uiCoords = CGAffineTransformScale(uiCoords, 1.0, -1.0);
-    CGContextConcatCTM(context, uiCoords);
-
-    CGContextConcatCTM(context, transform);
-    CGContextScaleCTM(context, 1.0, -1.0);
-
-    CGContextDrawImage(context, CGRectMake(-imageViewSize.width / 2, -imageViewSize.height / 2.0, imageViewSize.width,
-                                           imageViewSize.height),
-                       source);
-    CGImageRef resultRef = CGBitmapContextCreateImage(context);
-    CGContextRelease(context);
-    CGImageRelease(source);
-    return resultRef;
-}
-
-+ (CGImageRef)nx_newScaledImage:(CGImageRef)source toSize:(CGSize)size
-{
-    CGSize srcSize = size;
-    CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
-    CGContextRef context = CGBitmapContextCreate(NULL, size.width, size.height, 8, 0, rgbColorSpace,
-                                                 kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
-    CGColorSpaceRelease(rgbColorSpace);
-
-    CGContextSetInterpolationQuality(context, kCGInterpolationNone);
-    CGContextTranslateCTM(context, size.width / 2, size.height / 2);
-
-    CGContextDrawImage(context, CGRectMake(-srcSize.width / 2, -srcSize.height / 2, srcSize.width, srcSize.height),
-                       source);
-
-    CGImageRef resultRef = CGBitmapContextCreateImage(context);
-    CGContextRelease(context);
-    return resultRef;
-}
-
-#pragma mark - 圆角
-+ (UIImage *)nx_circleImage:(UIImage *)img
-{
-   return [self nx_circleImage:img cuttingDirection:UIRectCornerAllCorners cornerRadii:img.size.height/2. borderWidth:0 borderColor: [UIColor clearColor] backgroundColor: [UIColor clearColor]];
-}
-
-+ (UIImage *)nx_circleImage:(UIImage *)image cuttingDirection:(UIRectCorner)direction cornerRadii:(CGFloat)cornerRadii borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor backgroundColor:(UIColor *)backgroundColor
-{
-    //处理后的数据
-    UIImage * newImage = nil;
-    if (image.size.height != 0 && image.size.width != 0)
-    {
-        if (cornerRadii == 0)
-        {
-            cornerRadii = image.size.height / 2;
-        }
-        CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
-        UIGraphicsBeginImageContextWithOptions(rect.size, NO, [UIScreen mainScreen].scale);
-        CGContextRef currnetContext = UIGraphicsGetCurrentContext();
-        if (currnetContext) {
-            
-            UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:rect byRoundingCorners:direction cornerRadii:CGSizeMake(cornerRadii - borderWidth, cornerRadii - borderWidth)];
-            CGContextAddPath(currnetContext,path.CGPath);
-            CGContextClip(currnetContext);
-            
-            [image drawInRect:rect];
-            [borderColor setStroke];// 画笔颜色
-            [backgroundColor setFill];// 填充颜色
-            [path stroke];
-            [path fill];
-            newImage = UIGraphicsGetImageFromCurrentImageContext();
-            UIGraphicsEndImageContext();
-        }
-        
-        return newImage;
-    }
-    
-    return newImage;
-}
-
-+ (UIImage *)nx_launchImage
-{
-    CGSize viewSize  = [UIScreen mainScreen].bounds.size;
-    
-    NSString * viewOrientation = @"Portrait";
-    NSString * launchImageName = nil;
-    NSArray * imageDict = [[[NSBundle mainBundle] infoDictionary]valueForKey:@"UILaunchImages"];
-    for (NSDictionary  * dict in imageDict)
-    {
-        CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
-        if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
-        {
-            launchImageName = dict[@"UILaunchImageName"];
-        }
-    }
-    UIImage * launchImage = [UIImage imageNamed:launchImageName];
-    
-    return launchImage;
-}
-
-
-+ (UIImage*)transparentBackClear:(UIImage*)image color:(UIColor*)color
-{
-    // 分配内存
-    const int imageWidth = image.size.width;
-    const int imageHeight = image.size.height;
-    size_t bytesPerRow = imageWidth * 4;
-    uint32_t* rgbImageBuf = (uint32_t*)malloc(bytesPerRow * imageHeight);
-    
-    // 创建context
-    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-    CGContextRef context = CGBitmapContextCreate(rgbImageBuf, imageWidth, imageHeight, 8, bytesPerRow, colorSpace,
-                                                 kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipLast);
-    CGContextDrawImage(context, CGRectMake(0, 0, imageWidth, imageHeight), image.CGImage);
-    
-    // 遍历像素
-    int pixelNum = imageWidth * imageHeight;
-    uint32_t* pCurPtr = rgbImageBuf;
-    for (int i = 0; i < pixelNum; i++, pCurPtr++)
-    {
-        if ((*pCurPtr & 0xFFFFFF00) == 0xffffff00) {
-            
-            // 此处把白色背景颜色给变为透明
-            uint8_t* ptr = (uint8_t*)pCurPtr;
-            ptr[0] = 0;
-            
-        }else{
-            
-            // 改成下面的代码,会将图片转成想要的
-            //            uint8_t* ptr = (uint8_t*)pCurPtr;
-            //
-            //            ptr[3] = 0; //0~255
-            //
-            //            ptr[2] = 0;
-            //
-            //            ptr[1] = 0;
-        }
-    }
-    
-    // 将内存转成image
-    CGDataProviderRef dataProvider =CGDataProviderCreateWithData(NULL, rgbImageBuf, bytesPerRow * imageHeight, ProviderReleaseData);
-    
-    CGImageRef imageRef = CGImageCreate(imageWidth, imageHeight,8, 32, bytesPerRow, colorSpace,
-                                        kCGImageAlphaLast |kCGBitmapByteOrder32Little, dataProvider,
-                                        NULL, true,kCGRenderingIntentDefault);
-    CGDataProviderRelease(dataProvider);
-    
-    UIImage* resultUIImage = [UIImage imageWithCGImage:imageRef];
-    
-    // 释放
-    CGImageRelease(imageRef);
-    CGContextRelease(context);
-    CGColorSpaceRelease(colorSpace);
-    
-    return resultUIImage;
-}
-
-void ProviderReleaseData (void *info, const void *data, size_t size)
-{
-    free((void*)data);
-}
-
-@end

+ 0 - 39
BFCommonKit/Classes/BFUtility/PQCommonMethodUtil.swift

@@ -92,45 +92,6 @@ public func cIPHONE_X() -> Bool {
     return isX
 }
 
-/// 给按钮/imageView加载网络图片
-///
-/// - Parameters:
-///   - url: 网络url
-///   - mainView: 需要加载的视图
-public func netImage(url: String, mainView: Any, placeholder: UIImage = UIImage.moduleImage(named: "placehold_image", moduleName: "BFCommonKit") ?? UIImage()) {
-    if mainView is UIImageView {
-        (mainView as! UIImageView).kf.setImage(with: URL(string: url), placeholder: placeholder, options: url.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
-
-        }) { _ in
-        }
-    } else if mainView is UIButton {
-        (mainView as! UIButton).kf.setImage(with: URL(string: url), for: .normal, placeholder: placeholder, options: url.suffix(5) == ".webp" ? [.processor(WebPProcessor.default), .cacheSerializer(WebPSerializer.default)] : nil, progressBlock: { _, _ in
-
-        }) { _ in
-        }
-    }
-}
-
-/** 获取Kingfisher缓存的图片的data */
-public func kf_imageCacheData(originUrl: String) -> Data? {
-    let diskCachePath = ImageCache.default.cachePath(forKey: originUrl)
-    let data = try? Data(contentsOf: URL(fileURLWithPath: diskCachePath))
-    return data
-}
-
-/** 获取Kingfisher缓存的图片 */
-public func kf_imageCacheImage(originUrl: String, completeHandle: @escaping (_ image: UIImage?, _ error: Error?) -> Void) {
-    ImageCache.default.retrieveImageInDiskCache(forKey: originUrl, options: [.cacheOriginalImage]) { result in
-        DispatchQueue.main.async {
-            switch result {
-            case let .success(image):
-                completeHandle(image, nil)
-            case let .failure(error):
-                completeHandle(nil, error)
-            }
-        }
-    }
-}
 
 /** 打印
    type = 1 : 胡志强