swift_iosdev
在實際的App開發迭代過程中,為了提高代碼的復用率和提升開發效率,我們經常會在項目中設計一些工具類、擴展和模塊化組件。
為了讓大家進一步解放雙手,今天推薦一款 Swift 便捷工具庫-CXSwiftKit。
預覽
更多內容需要你來探索。
IMG_0717.gif
如果覺得還行呢,就麻煩順手給個star
特色
-
ApplePay
(可選)
:用于蘋果支付。 - AVToolbox:用于錄音、音視頻格式轉換。
- Base:包含配置、定義和日志輸出等。
- Core:包含APP重簽檢測、獲取設備信息、相冊操作、錄屏、截屏檢測、跳轉等。
- Camera:用于iOS相機采樣數據捕獲。
- DocumentPicker:用于系統文件操作。
-
Extension:包含
Array、Dictionary、Int、Double、CGFloat、String、NSAttributedString、CALayer、NSObject、DispatchQueue、UIDevice、UIColor、UIImage、UIImageView、UIView、UIViewController
等擴展。 - FileOperation:用于iOS沙盒文件操作。
-
KingfisherWrapper
(可選)
:Kingfisher的防盜鏈設置、UIButton/UIImageView快速設置圖片擴展,常用功能封裝。 - LiveGift:用于展示直播小禮物贈送
- OverlayView:用于彈出上下左右各個方向的覆蓋視圖。
- Permissions:用于iOS的照片庫、相機、麥克風、位置、藍牙、通訊錄、提醒、日歷、Siri、通知、追蹤等各種權限。
- Timer:封裝了DispatchTimer和Timer。
- Transition:用于過渡場景切換。
- Widget:自定義控件。
-
SDWebImageWrapper
(可選)
:SDWebImage的防盜鏈設置和常用功能封裝。
要求
Xcode 14.0+
iOS 11.0, tvOS 11.0, macOS 10.15, watchOS 5.0
安裝
通過CocoaPods獲得。安裝只需將下面的添加到您的Podfile中:
- CXSwiftKit
pod 'CXSwiftKit'
- ApplePay
pod 'CXSwiftKit/ApplePay'
- KingfisherWrapper
pod 'CXSwiftKit/KingfisherWrapper'
- SDWebImageWrapper
pod 'CXSwiftKit/SDWebImageWrapper'
結構說明
CXSwiftKit
┣ ApplePay
┃ ┗ CXApplePayContext.swift // The implementation for Apple payment.
┃
┣ Base
┃ ┣
┃ ┣ CXConfig.swift // The configuration of this kit.
┃ ┣ CXDefines.swift // The definitions of this kit.
┃ ┣ CXLock.swift // Includes multi-thread locks(`CXUnfairLock, CXMutex, CXRecursiveMutex, CXSpin, CXConditionLock`).
┃ ┗ CXLogger.swift // Outputs logs to the console.
┃
┣ Core
┃ ┣ CXAppContext.swift
┃ ┣ CXDevice.swift // Used to provide some device informations.
┃ ┣ CXDeviceScreenMonitor.swift // Used to observe some changes of device screen.
┃ ┣ CXHaptics.swift // Some haptic feedback that works on iPhone 6 and up.
┃ ┣ CXImageBufferProcessor.swift // Used to process image buffer.
┃ ┣ CXPhotoLibraryOperator.swift // Used to operate the photo library.
┃ ┣ CXScreenRecorder.swift // The recorder that provides the ability to record audio and video of your app.
┃ ┣ CXSwiftUtils.swift
┃ ┣ CXSwipeInteractor.swift // Add swipe gesture for the view, and observe its action.
┃ ┗ CXTakeScreenshotDetector.swift // The detector for taking screenshot.
┃ ┣ AVToolbox
┃ ┃ ┣ CXAudioRecorder.swift // The audio recorder that records audio data to a file.
┃ ┃ ┣ CXAudioToolbox.swift // Used to handle audio format.
┃ ┃ ┣ CXAVGlobal.swift // The global methods for the exported position.
┃ ┃ ┣ CXAVToolbox.swift // Used to handle audio and video mix.
┃ ┃ ┗ CXVideoToolbox.swift // Used to convert mp4 video format.
┃ ┣ Camera
┃ ┃ ┣ AtomicWrapper.swift // Used to wrap atomic property.
┃ ┃ ┣ CXLiveCameraConfiguration.swift // The configuration for live camera.
┃ ┃ ┣ CXLiveCameraFrameCapturer.swift
┃ ┃ ┣ CXLiveCameraFrameRenderer.swift
┃ ┃ ┣ CXLiveCameraPreview.swift
┃ ┃ ┣ CXLiveCameraProtocol.swift
┃ ┃ ┣ CXScanProtocol.swift
┃ ┃ ┣ CXScanResult.swift
┃ ┃ ┗ CXScanWrapper.swift
┃ ┣ CustomOverlayView
┃ ┃ ┣ CXOverlayViewControllerWrapable.swift
┃ ┃ ┣ CXOverlayViewEx.swift
┃ ┃ ┗ CXOverlayViewWrapable.swift
┃ ┣ DocumentPicker // The document picker for iOS.
┃ ┃ ┣ CXDocument.swift
┃ ┃ ┣ CXDocumentDelegate.swift
┃ ┃ ┣ CXDocumentPicker.swift
┃ ┃ ┗ CXDocumentDelegate.swift
┃ ┣ LiveGift // Used to show live gifts.
┃ ┃ ┣ CXLiveGiftLabel.swift
┃ ┃ ┣ CXLiveGiftManager.swift
┃ ┃ ┣ CXLiveGiftModel.swift
┃ ┃ ┣ CXLiveGiftOperation.swift
┃ ┃ ┗ CXLiveGiftView.swift
┃ ┣ Permissions
┃ ┃ ┣ CXPermission.swift
┃ ┃ ┣ CXPermissionResult.swift
┃ ┃ ┣ CXPermissions.swift // Includes photos, camera, microphone, locationAlways, locationInUse, notification, bluetooth,
┃ ┃ ┃ // deviceBiometrics, devicePasscode, contacts, reminder, event, motion, siri, health, media, appTracking.
┃ ┃ ┣ CXPermissionStatus.swift
┃ ┃ ┣ CXPermissionType.swift
┃ ┣ Timer
┃ ┃ ┣ CXDispatchTimer.swift
┃ ┃ ┗ CXTimer.swift
┃ ┣ Transition // Views the demo in CXScalePresentAnimation.swift.
┃ ┃ ┣ CXScaleDismissAnimation.swift
┃ ┃ ┣ CXScalePresentAnimation.swift
┃ ┃ ┗ CXSwipeLeftInteractiveTransition.swift
┃ ┗ Widget
┃ ┣ CXCircleProgressButton.swift // The circle progress button for iOS or tvOS.
┃ ┗ CXVerticalSlider.swift // The vertical slider for iOS or tvOS.
┃
┣ Extension // Provides some rich extensions
┃ ┣ Application+Cx.swift
┃ ┣ Array+Cx.swift
┃ ┣ AVAsset+Cx.swift
┃ ┣ Button+Cx.swift
┃ ┣ CALayer+Cx.swift
┃ ┣ CGFloat+Cx.swift
┃ ┣ Color+Cx.swift
┃ ┣ CXAssociatedKey.swift // Includes the associated keys.
┃ ┣ CXConstraintMaker.swift
┃ ┣ CXGlobal.swift // Provides some global methods
┃ ┣ CXSwiftBase.swift // Declares a `CXSwiftBaseCompatible` protocol, etc. You can use `cx` in the app, e.g.: view.cx.right = 10
┃ ┣ Date+Cx.swift
┃ ┣ Device+Cx.swift
┃ ┣ Dictionary+Cx.swift
┃ ┣ DispatchQueue+Cx.swift
┃ ┣ Double+Cx.swift
┃ ┣ Font+Cx.swift
┃ ┣ Image+Cx.swift
┃ ┣ ImageView+Cx.swift
┃ ┣ Int+Cx.swift
┃ ┣ Label+Cx.swift
┃ ┣ NSAttributedString+Cx.swift
┃ ┣ NSObject+Cx.swift
┃ ┣ Optional+Cx.swift
┃ ┣ ScrollView+Cx.swift
┃ ┣ String+Cx.swift
┃ ┣ TableView+Cx.swift
┃ ┣ TextField+Cx.swift
┃ ┣ TextView+Cx.swift
┃ ┣ URL+Cx.swift
┃ ┣ View+Cx.swift
┃ ┗ ViewController+Cx.swift
┃
┣ FileOperation
┃ ┣ CXFileToolbox.swift // The file toolbox.
┃ ┣ CXLineReader.swift // Read text file line by line in efficient way.
┃ ┗ CXStreamReader.swift // The file descriptor accesses data associated with files.
┃
┣ KingfisherWrapper
┃ ┣ Button+kfwrapper.swift
┃ ┣ CXKingfisherReferer.swift // Anti theft chains for files such as images and videos, and so on.
┃ ┗ ImageView+kfwrapper.swift
┃
┗ SDWebImageWrapper
┗ SDWebImageWrapper.swift // The wrapper for SDWebImage.
推薦
- CXDownload - 實現Swift斷點續傳下載,包含大文件下載,后臺下載,殺死進程,重新啟動時繼續下載,設置下載并發數,監聽網絡改變等。
-
MarsUIKit -
MarsUIKit
封裝一些常用的UI組件,如:Toast, Messages, HUD, EmptyDataSet, SVGA, and so on.
。 -
RxListDataSource -
RxListDataSource
為UITableView
或UICollectionView
提供數據源和數據綁定。 -
CXNetwork-Moya -
CXNetwork-Moya
基于Moya
和ObjectMapper
封裝的一個網絡請求庫。
反饋
附上Demo地址,有任何遇到的問題,歡迎留言或提issue。