🐻 個人開發app利器

SpeedySwift

這是一個app開發的加速庫,個人幾款app都是基於這個加速庫完成的git

儘可能保持開發的原汁原味,歡迎使用,喜歡star✨緩存

我想目前Swift中沒有比這個更合適的加速開發app的框架了,若是有請告訴我。 地址:https://github.com/Tliens/SpeedySwift安全

2021-01-08 更新

  • 新增本地通知庫 (方便本地通知,定時通知,取消通知,DLLocalNotification取消時會崩潰,已修復放在O5_Vendor中)
  • 擴展添加show alert的快捷方法
  • 增長經過cell上的控件獲取cell、index(十分有用)
  • 增長random(讓swift中的random變得更加好用)
  • 暗黑模式主題適配 color(day:UIColor,night:UIColor)->UIColor
  • 增長textiew+placeholder
  • AppViewController內增長避免scrollview可能出現的offset問題

特點:

如何使用

下載最新代碼後,將AppSpeedy拖入到工程中,暫不支持podmarkdown

要求:Swift5.0及以上網絡

代碼演示

  • 顏色
UIColor.hex("#22023b")
複製代碼
  • 底部安全區高度
let height = App.safeBottomHeight
複製代碼
  • 字符串提取
"Hello World!"[safe: 3] -> "l"
複製代碼
  • 不用關心方向的 AppCollectionViewLayout
let layout = AppCollectionViewLayout(longitude: 0, latitude: 10.scale, itemSize: CGSize(width: 130.scale, height: 139.scale), sectionInset: .init(top: 10.scale, left: 20.scale, bottom: 0, right: 20.scale), direction: .vertical)
複製代碼
  • 屬性包裹器
/// codable👍
@Default<String.defalut> var name:String

/// 數據持久化👍
@UserDefault("had_shown_guide_view", defaultValue: false)
static var hadShownGuideView: Bool

複製代碼
  • 系統頁跳轉
/// 跳轉到系統頁面
    /// - Parameter type: 類型
    /// - Parameter completionHandler:  block回調,bool表示是否成功
    static func systemJump(completionHandler completion: ((AppJumpStatus) -> Void)? = nil){
        let urlString = UIApplication.openSettingsURLString
        if let url: URL = URL(string: urlString) {
            App.jump(url: url, completionHandler: completion)
        }else{
            completion?(.fail)
        }
    }
複製代碼
  • 增長經過cell上的控件獲取cell、index
/// 獲取indexpath
    func indexPath(by child:UIView)->IndexPath?{
        let point = child.convert(CGPoint.zero, to: self)
        return self.indexPathForRow(at: point)
    }
    /// 獲取cell
    func cell(by child:UIView)->UITableViewCell?{
        let point = child.convert(CGPoint.zero, to: self)
        if let indexPath = self.indexPathForRow(at: point){
            return self.cellForRow(at: indexPath)
        }
        return nil
    }

複製代碼
  • 其餘
/// app版本號
    static var version: String? {
        return Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
    }
    /// 設備名稱
    static var deviceName: String {
        return UIDevice.current.localizedModel
    }
    /// 設備方向
    static var deviceOrientation: UIDeviceOrientation {
        return UIDevice.current.orientation
    }
    /// 主窗口
    static var keyWindow: UIView? {
        return UIApplication.shared.keyWindow
    }
    /// 當前系統版本
    static var systemVersion: String {
        return UIDevice.current.systemVersion
    }
    /// 判斷設備是否是iPhoneX
    static var isX : Bool {
        var isX = false
        if #available(iOS 11.0, *) {
            let bottom : CGFloat = UIApplication.shared.delegate?.window??.safeAreaInsets.bottom ?? 0
            isX = bottom > 0.0
        }
        return isX
    }
複製代碼

等你發現更多······app

地址:github.com/Tliens/Spee… 歡迎使用,喜歡請star✨框架

結構介紹

我根據使用頻率以及層次結構分爲了:dom

  • O1_Base
  • O2_Core
  • O3_Foundation
  • O4_UI
  • O5_Vendor
  • O6_Resource

O1_Base 文件夾下包含 app跳轉、沙盒使用、AppCollectionViewLayoutViewcontrolleNavigationControllerTabbarController 基礎封裝

O2_Core 屬性包裹器、DebugRandom

O3_Foundation Foundation框架的經常使用擴展

O4_UI UIKit框架的經常使用擴展

O5_Vendor 強大的CPCollectionViewKit、震動反饋、Snapkit、Toast

O6_Resource 資源文件

地址:github.com/Tliens/Spee… 歡迎使用,喜歡請star✨

相關文章
相關標籤/搜索