Browse Source

设置公开方法

jsonwang 3 years ago
parent
commit
ca604352f7

+ 2 - 2
BFFramework/Classes/Categorys/Bundle+Ext.swift

@@ -10,12 +10,12 @@ import Foundation
 extension Bundle {
     
     // bf main bundle url
-    func BF_mainbundle_URL() -> URL {
+   public func BF_mainbundle_URL() -> URL {
         let bundle:Bundle = Bundle.init(for: PQBaseViewController.self)
         return bundle.url(forResource: "BFFramework", withExtension: "bundle")!
     }
     // bf main bundle
-    func BF_mainbundle() -> Bundle {
+    public func BF_mainbundle() -> Bundle {
         return  Bundle.init(url: BF_mainbundle_URL())!
     }
  

+ 2 - 2
BFFramework/Classes/Categorys/Int+Ext.swift

@@ -54,7 +54,7 @@ extension Int {
 extension Float64 {
     /// 时长转化为分秒 62'52"
     /// - Returns: <#description#>
-    func formatDurationToMS() -> String {
+    public func formatDurationToMS() -> String {
         let duration = lround(self)
         var text = ""
         let min = duration / 60
@@ -72,7 +72,7 @@ extension Float64 {
     /// 时长转化成时分秒 01:02:52
     /// - Parameter value: <#value description#>
     /// - Returns: <#description#>
-    func formatDurationToHMS() -> String {
+    public  func formatDurationToHMS() -> String {
         var theTime = lround(self)
         var theTime1 = 0 // 分
         var theTime2 = 0 // 小时

+ 9 - 9
BFFramework/Classes/Categorys/String+Ext.swift

@@ -11,11 +11,11 @@ import MobileCoreServices
 
 extension String {
     // 文件后缀名
-    var pathExtension: String {
+    public  var pathExtension: String {
         return (self as NSString).pathExtension
     }
 
-    func enumerateSearchText(searchText: String?, complate: (_ idx: Int, _ range: NSRange) -> Void) {
+    public  func enumerateSearchText(searchText: String?, complate: (_ idx: Int, _ range: NSRange) -> Void) {
         if searchText == nil || (searchText?.count ?? 0) <= 0 || !contains(searchText!) {
             return
         }
@@ -33,7 +33,7 @@ extension String {
         }
     }
 
-    func attributedTextWithSearchText(searchText: String?, textColor: UIColor, textFont: UIFont, searchTextColor: UIColor, searchTextFont: UIFont) -> NSMutableAttributedString {
+    public  func attributedTextWithSearchText(searchText: String?, textColor: UIColor, textFont: UIFont, searchTextColor: UIColor, searchTextFont: UIFont) -> NSMutableAttributedString {
         let attbText = NSMutableAttributedString(string: self, attributes: [NSAttributedString.Key.font: textFont, NSAttributedString.Key.foregroundColor: textColor])
         if count <= 0 || searchText == nil || (searchText?.count ?? 0) <= 0 {
             return attbText
@@ -48,14 +48,14 @@ extension String {
     }
 
     // 判断是否为空
-    var isSpace: Bool {
+    public  var isSpace: Bool {
         return allSatisfy { $0.isWhitespace }
     }
 
     /// 通过 文件路径/文件名/文件后缀 获取mimeType(文件媒体类型)
     /// - Parameter pathExtension: <#pathExtension description#>
     /// - Returns: <#description#>
-    func mimeType() -> String {
+    public func mimeType() -> String {
         if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (self as NSString).pathExtension as CFString, nil)?.takeRetainedValue() {
             if let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?
                 .takeRetainedValue()
@@ -67,19 +67,19 @@ extension String {
     }
 
     // 将原始的url编码为合法的url
-    func urlEncoded() -> String {
+    public  func urlEncoded() -> String {
         let encodeUrlString = addingPercentEncoding(withAllowedCharacters:
             .urlQueryAllowed)
         return encodeUrlString ?? ""
     }
 
     // 将编码后的url转换回原始的url
-    func urlDecoded() -> String {
+    public func urlDecoded() -> String {
         return removingPercentEncoding ?? ""
     }
 
     // 判断是否包含Emoji表情
-    func isEmoji() -> Bool {
+    public func isEmoji() -> Bool {
         let numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
         guard !numbers.contains(self) else {
             return false
@@ -163,7 +163,7 @@ extension String {
 }
 
 extension Optional where Wrapped == String {
-    var isSpace: Bool {
+    public var isSpace: Bool {
         return self?.isSpace ?? true
     }
 }

+ 2 - 2
BFFramework/Classes/Categorys/UIButton+ext.swift

@@ -13,13 +13,13 @@
  - right:  图像在右
  - bottom: 图像在下
  */
-enum PQButtonImageEdgeInsetsStyle {
+public enum PQButtonImageEdgeInsetsStyle {
     case top, left, right, bottom
 }
 
 import Foundation
 extension UIButton {
-    func imagePosition(at style: PQButtonImageEdgeInsetsStyle, space: CGFloat) {
+    public func imagePosition(at style: PQButtonImageEdgeInsetsStyle, space: CGFloat) {
         guard let imageV = imageView else { return }
         guard let titleL = titleLabel else { return }
         // 获取图像的宽和高

+ 1 - 1
BFFramework/Classes/Categorys/UIColor+Ext.swift

@@ -10,7 +10,7 @@ import Foundation
 import UIKit
 
 extension UIColor {
-    class func hexColor(hexadecimal: String) -> UIColor {
+    public  class func hexColor(hexadecimal: String) -> UIColor {
         var cstr = hexadecimal.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).uppercased() as NSString
         if cstr.length < 6 {
             return UIColor.clear

+ 9 - 9
BFFramework/Classes/Categorys/UIImage+Ext.swift

@@ -11,14 +11,14 @@ import Foundation
 extension UIImage {
     
     //从BFframwork bundle 中取图片
-    func BF_Image(named:String) -> UIImage {
+    public func BF_Image(named:String) -> UIImage {
   
         let image:UIImage = UIImage.init(named: named, in:  Bundle.init().BF_mainbundle(), compatibleWith: nil) ?? UIImage.init()
         return image
         
     }
  
-    func cropImage(ratio: CGFloat) -> UIImage {
+    public func cropImage(ratio: CGFloat) -> UIImage {
         // 计算最终尺寸
         let newSize: CGSize = CGSize(width: size.width, height: size.width * ratio)
         // 图片绘制区域
@@ -36,7 +36,7 @@ extension UIImage {
         return scaledImage!
     }
 
-    func cropImage(newSize: CGSize) -> UIImage {
+    public func cropImage(newSize: CGSize) -> UIImage {
         //// 图片绘制区域
         var rect = CGRect.zero
         rect.size.width = newSize.width
@@ -50,7 +50,7 @@ extension UIImage {
         return scaledImage!
     }
 
-    func imageWithImage(scaledToSize newSize: CGSize) -> UIImage {
+    public func imageWithImage(scaledToSize newSize: CGSize) -> UIImage {
         UIGraphicsBeginImageContextWithOptions(newSize, false, 0.0)
         draw(in: CGRect(origin: CGPoint.zero, size: newSize))
         let newImage = UIGraphicsGetImageFromCurrentImageContext() ?? self
@@ -61,7 +61,7 @@ extension UIImage {
     /// 旋转角度
     /// - Parameter image: <#image description#>
     /// - Returns: <#description#>
-    func rotateImage(rotate: Int, originWidth: CGFloat, originHeight: CGFloat) -> UIImage {
+    public 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
@@ -85,7 +85,7 @@ extension UIImage {
     ///   - tintColor: <#tintColor description#>
     ///   - convert:是否倒置
     /// - Returns: <#description#>
-    class func triangleImage(size: CGSize, tintColor: UIColor, direction: moveDirection = .moveDirectionDown) -> UIImage {
+    public 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
@@ -123,7 +123,7 @@ extension UIImage {
 
     /// 按照最短边缩放  add by ak
     /// - Parameter maxLength: 边长最大值
-    func nx_scaleWithMaxLength(maxLength: CGFloat) -> UIImage {
+    public func nx_scaleWithMaxLength(maxLength: CGFloat) -> UIImage {
         if size.width > maxLength || size.height > maxLength {
             var maxWidth: CGFloat = maxLength
             var maxHeight: CGFloat = maxLength
@@ -149,7 +149,7 @@ extension UIImage {
 
     /// 缩放到指定大小 add by ak
     /// - Parameter size: 新的大小
-    func nx_scaleToSize(size: CGSize) -> UIImage {
+    public func nx_scaleToSize(size: CGSize) -> UIImage {
         var width: CGFloat = CGFloat(cgImage!.width)
         var height: CGFloat = CGFloat(cgImage!.height)
 
@@ -193,7 +193,7 @@ extension UIImage {
     }
 
     // 将图片裁剪成指定比例(多余部分自动删除)let image3 = image.crop(ratio: 1) /将图片转成 1:1 比例(正方形)
-    func nxcrop(ratio: CGFloat) -> UIImage {
+    public func nxcrop(ratio: CGFloat) -> UIImage {
         // 计算最终尺寸
         var newSize: CGSize!
         if size.width / size.height > ratio {

+ 28 - 28
BFFramework/Classes/Categorys/UIView+Ext.swift

@@ -13,7 +13,7 @@ import UIKit
 
 /// UIView的分类扩展
 extension UIView {
-   public func addCorner(roundingCorners: UIRectCorner = .allCorners, corner: CGFloat = cDefaultMargin) {
+      public func addCorner(roundingCorners: UIRectCorner = .allCorners, corner: CGFloat = cDefaultMargin) {
         if roundingCorners == .allCorners {
             layer.cornerRadius = corner
             layer.masksToBounds = true
@@ -31,7 +31,7 @@ extension UIView {
     ///   - 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)) {
+     public 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
@@ -48,7 +48,7 @@ extension UIView {
     }
 
     /// 添加虚线条
-    func addBorderToLayer(frame: CGRect? = nil) {
+     public func addBorderToLayer(frame: CGRect? = nil) {
         // 线条颜色
         let borderLayer: CAShapeLayer = CAShapeLayer()
         borderLayer.strokeColor = UIColor.hexColor(hexadecimal: "#FFFFFF").cgColor
@@ -62,7 +62,7 @@ extension UIView {
         layer.addSublayer(borderLayer)
     }
 
-    func animateZoom() {
+     public 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)
@@ -81,7 +81,7 @@ extension UIView {
     ///   - duration: <#duration description#>
     ///   - repeatCount: <#repeatCount description#>
     /// - Returns: <#description#>
-    func shakeAnimation(_ fromValue: Float, _ toValue: Float, _ duration: Float, _: Float) {
+     public func shakeAnimation(_ fromValue: Float, _ toValue: Float, _ duration: Float, _: Float) {
         layer.removeAllAnimations()
         let shake = CABasicAnimation(keyPath: "transform.rotation.z")
         shake.fromValue = fromValue
@@ -101,7 +101,7 @@ extension UIView {
     ///   - isRepeat: <#isRepeat description#>
     ///   - multiple: <#multiple description#>
     /// - Returns: <#description#>
-    func heartbeatAnimate(duration: TimeInterval, isRepeat: Bool, multiple: CGFloat) {
+     public 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
@@ -127,7 +127,7 @@ extension UIView {
 
     /// 活动心跳动画
     /// - Returns: <#description#>
-    func activityHeartbeatAnimate() {
+     public func activityHeartbeatAnimate() {
         layer.removeAllAnimations()
         UIView.animateKeyframes(withDuration: 0.45, delay: 0, options: .allowUserInteraction, animations: {
             self.transform = CGAffineTransform(scaleX: 0.9, y: 0.9)
@@ -142,7 +142,7 @@ extension UIView {
 
     /// 活动心跳动画
     /// - Returns: <#description#>
-    func heartbeatAnimate() {
+     public func heartbeatAnimate() {
         layer.removeAllAnimations()
         UIView.animateKeyframes(withDuration: 1, delay: 0, options: .allowUserInteraction, animations: {
             self.transform = CGAffineTransform(scaleX: 1.3, y: 1.3)
@@ -157,7 +157,7 @@ extension UIView {
         }
     }
 
-    func addScaleBasicAnimation() {
+     public func addScaleBasicAnimation() {
         let animation = CABasicAnimation(keyPath: "transform.scale")
         animation.timingFunction = CAMediaTimingFunction(name: .easeOut)
         animation.duration = 0.5
@@ -168,7 +168,7 @@ extension UIView {
         layer.add(animation, forKey: nil)
     }
 
-    func addScaleYBasicAnimation() {
+     public func addScaleYBasicAnimation() {
         let animation = CAKeyframeAnimation(keyPath: "transform.translation.y")
         animation.duration = 0.5
         animation.repeatCount = 100
@@ -191,7 +191,7 @@ extension UIView {
 
     /// 将view生成一张图片
     /// - Returns: <#description#>
-    func graphicsGetImage() -> UIImage? {
+     public func graphicsGetImage() -> UIImage? {
         UIGraphicsBeginImageContextWithOptions(frame.size, true, 0.0)
         layer.render(in: UIGraphicsGetCurrentContext()!)
         let newImage = UIGraphicsGetImageFromCurrentImageContext()
@@ -201,7 +201,7 @@ extension UIView {
 
     /// 动画显示View
     /// - Returns: <#description#>
-    func showViewAnimate(duration: TimeInterval = 0.3, completion: ((Bool) -> Void)? = nil) {
+     public func showViewAnimate(duration: TimeInterval = 0.3, completion: ((Bool) -> Void)? = nil) {
         UIView.animate(withDuration: duration, animations: { [weak self] in
             self?.frame = CGRect(x: 0, y: cScreenHeigth - self!.frame.height, width: self!.frame.width, height: self!.frame.height)
         }) { isFinished in
@@ -213,7 +213,7 @@ extension UIView {
 
     /// 动画隐藏view
     /// - Returns: <#description#>
-    func dismissViewAnimate(duration: TimeInterval = 0.3, completion: ((Bool) -> Void)? = nil) {
+     public func dismissViewAnimate(duration: TimeInterval = 0.3, completion: ((Bool) -> Void)? = nil) {
         UIView.animate(withDuration: duration, animations: { [weak self] in
             self?.frame = CGRect(x: 0, y: cScreenHeigth, width: self!.frame.width, height: self!.frame.height)
         }) { isFinished in
@@ -226,7 +226,7 @@ extension UIView {
     /// add  by ak 添加虚线框
     /// - Parameter color: 框色
     /// - Parameter lineWidth: 框宽
-    func addBorderToLayer(color: CGColor, lineWidth: CGFloat) {
+     public func addBorderToLayer(color: CGColor, lineWidth: CGFloat) {
         let border = CAShapeLayer()
 
         //  线条颜色
@@ -251,7 +251,7 @@ extension UIView {
 extension UICollectionView {
     /// 获取当前cell
     /// - Returns: <#description#>
-    func visibleCell() -> UICollectionViewCell? {
+     public 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 }
@@ -262,7 +262,7 @@ extension UICollectionView {
     /// - Parameters:
     ///   - scroller: <#scroller description#>
     ///   - type: 1-头部跟尾部 2-头部 3-尾部
-    func addRefreshView(type: REFRESH_TYPE = .REFRESH_TYPE_ALL, refreshHandle: ((_ isHeader: Bool) -> Void)?) {
+     public func addRefreshView(type: REFRESH_TYPE = .REFRESH_TYPE_ALL, refreshHandle: ((_ isHeader: Bool) -> Void)?) {
         if type == .REFRESH_TYPE_ALL || type == .REFRESH_TYPE_HEADER {
             let header = MJRefreshNormalHeader.init {
                 if refreshHandle != nil {
@@ -290,7 +290,7 @@ extension UICollectionView {
         }
     }
 
-    func indexPathsForElements(in rect: CGRect) -> [IndexPath] {
+     public func indexPathsForElements(in rect: CGRect) -> [IndexPath] {
         let allLayoutAttributes = collectionViewLayout.layoutAttributesForElements(in: rect)!
         return allLayoutAttributes.map { $0.indexPath }
     }
@@ -303,7 +303,7 @@ extension UITabBar {
     /// 展示小红点
     /// - Parameter index: <#index description#>
     /// - Returns: <#description#>
-    func showPoint(index: Int) {
+     public func showPoint(index: Int) {
         let pointW: CGFloat = 8
         let pointView = UIView()
         pointView.tag = 11111 + index
@@ -319,7 +319,7 @@ extension UITabBar {
     /// 移除小红点
     /// - Parameter index: <#index description#>
     /// - Returns: <#description#>
-    func removePoint(index: Int) {
+     public func removePoint(index: Int) {
         for item in subviews {
             if item.tag == 11111 + index {
                 item.removeFromSuperview()
@@ -330,7 +330,7 @@ extension UITabBar {
     /// 展示创作视频引导
     /// - Parameter index: <#index description#>
     /// - Returns: <#description#>
-    func showVideoMakeRemindView() {
+     public func showVideoMakeRemindView() {
         let isOldUploadClick: String? = getUserDefaults(key: cIsUploadClick) as? String
         let isUploadClick: String? = getUserDefaultsForJson(key: cIsUploadClick) as? String
         let isVerticalSlip: String? = getUserDefaults(key: cIsVerticalSlip) as? String
@@ -355,13 +355,13 @@ extension UITabBar {
         }
     }
 
-    @objc func dismiss() {
+    @objc  public func dismiss() {
   
     }
 
     /// 移除创作视频引导
     /// - Returns: <#description#>
-    func removeVideoMakeRemindView() {
+     public func removeVideoMakeRemindView() {
         viewWithTag(cVideoMakeRemindTag)?.removeFromSuperview()
     }
 }
@@ -399,7 +399,7 @@ extension UILabel {
     ///   - color: <#color description#>
     ///   - offset: <#offset description#>
     /// - Returns: <#description#>
-    func addShadow(color: UIColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5), offset: CGSize = CGSize(width: 1, height: 1)) {
+     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
     }
@@ -409,7 +409,7 @@ extension UIImageView {
     /// imageView加载网络图片
     /// - Parameters:
     ///   - url: 网络url
-    func setNetImage(url: String?, placeholder: UIImage = UIImage(named: "placehold_image")!) {
+     public func setNetImage(url: String?, placeholder: UIImage = UIImage(named: "placehold_image")!) {
         if url == nil || (url?.count ?? 0) <= 0 {
             BFLog(message: "设置按钮网络图片地址为空")
             return
@@ -422,7 +422,7 @@ extension UIImageView {
 
     /// 展示加载中动画
     /// - Returns: <#description#>
-    func showLoadingAnimation(duration: Double = 1) {
+     public func showLoadingAnimation(duration: Double = 1) {
         let rotationAnim = CABasicAnimation(keyPath: "transform.rotation.z")
         rotationAnim.fromValue = 0
         rotationAnim.toValue = Double.pi * 2
@@ -439,7 +439,7 @@ extension UIImageView {
     ///   - repeatCount: 循环次数
     ///   - duration: 时长
     /// - Returns: <#description#>
-    func displayGIF(data: Data? = nil, images: [UIImage]? = nil, repeatCount: Int = Int.max, duration: Double = 1) {
+     public 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()
@@ -461,7 +461,7 @@ extension UIButton {
     /// UIButton加载网络图片
     /// - Parameters:
     ///   - url: 网络url
-    func setNetImage(url: String?, placeholder: UIImage = UIImage(named: "placehold_image")!) {
+     public func setNetImage(url: String?, placeholder: UIImage = UIImage(named: "placehold_image")!) {
         if url == nil || (url?.count ?? 0) <= 0 {
             BFLog(message: "设置按钮网络图片地址为空")
             return
@@ -475,7 +475,7 @@ extension UIButton {
     /// UIButton加载网络背景图片
     /// - Parameters:
     ///   - url: 网络url
-    func setNetBackgroundImage(url: String, placeholder: UIImage = UIImage(named: "placehold_image")!) {
+     public func setNetBackgroundImage(url: String, placeholder: UIImage = UIImage(named: "placehold_image")!) {
 //        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

+ 3 - 3
BFFramework/Classes/Enums/Enums.swift

@@ -465,7 +465,7 @@ enum TAB_PAGETYPE: String {
 // MARK: - 刷新控件类型
 
 /// 刷新控件类型
-enum REFRESH_TYPE {
+public enum REFRESH_TYPE {
     case REFRESH_TYPE_ALL // 推荐
     case REFRESH_TYPE_HEADER // 头部
     case REFRESH_TYPE_FOOTER // 尾部
@@ -474,7 +474,7 @@ enum REFRESH_TYPE {
 // MARK: - 刷新控件类型
 
 /// 刷新控件类型
-enum moveDirection {
+public enum moveDirection {
     case moveDirectionNormal
     case moveDirectionUp
     case moveDirectionDown
@@ -716,7 +716,7 @@ enum stuckPointMusicContentType {
 }
 
 // 视频发布来源场景 1:普通上传 2:创作工具,3:普通上传转创作工具,4:后台转换加工,5:卡点视频制作
-enum videoFromScene: Int {
+public enum videoFromScene: Int {
     case UploadNormal = 1 // 普通上传
     case UploadMakeVideo = 2 // 创作工具
     case UploadNormalToMakeVideo = 3 // 普通上传转创作工具