玩轉iOS開發:本身造的輪子《CLUIKit》

CLUIKit

CocoaPods Compatible
Carthage Compatible
Platform
Language

CLUIKit簡介

CLUIKit是對系統UIKit API進行擴展, 以及一些本身封裝的UI, API的用法所有都在CLUIKitExample裏, 若是在使用庫遇到的一些疑惑歡迎隨時Issues給我.html

支持CocoaPod管理ios

pod 'CLUIKit'git

支助

若是您以爲挺讚的話, 能夠給我打賞打賞, 謝謝啦~github

支付寶

CLAnimatorManager

CLAnimatorManager是針對系統的UIViewPropertyAnimator封裝的一個類庫, 只支持iOS 10以後的系統.web

UICubicTimingParameters

- (void)cl_cubicTimingParametersWithDuration:(NSTimeInterval)duration
                                       curve:(UIViewAnimationCurve)curve
                                  animations:(CLAnimatorManagerBlock)animations NS_AVAILABLE_IOS(10_0);

- (void)cl_cubicTimingParametersWithDuration:(NSTimeInterval)duration
                                       curve:(UIViewAnimationCurve)curve
                                  animations:(CLAnimatorManagerBlock)animations
                                  completion:(CLAnimatorManagerCompleteBlock)completion NS_AVAILABLE_IOS(10_0);

- (void)cl_cubicTimingParametersWithDuration:(NSTimeInterval)duration
                               controlPoint1:(CGPoint)controlPoint1
                               controlPoint2:(CGPoint)controlPoint2
                                  animations:(CLAnimatorManagerBlock)animations NS_AVAILABLE_IOS(10_0);

- (void)cl_cubicTimingParametersWithDuration:(NSTimeInterval)duration
                               controlPoint1:(CGPoint)controlPoint1
                               controlPoint2:(CGPoint)controlPoint2
                                  animations:(CLAnimatorManagerBlock)animations
                                  completion:(CLAnimatorManagerCompleteBlock)completion NS_AVAILABLE_IOS(10_0);
複製代碼

UISpringTimingParameters

- (void)cl_springTimingParametersWithDuration:(NSTimeInterval)duration
                                 dampingRatio:(CGFloat)dampingRatio
                                   animations:(CLAnimatorManagerBlock)animations NS_AVAILABLE_IOS(10_0);

- (void)cl_springTimingParametersWithDuration:(NSTimeInterval)duration
                                 dampingRatio:(CGFloat)dampingRatio
                                   animations:(CLAnimatorManagerBlock)animations
                                   completion:(CLAnimatorManagerCompleteBlock)completion NS_AVAILABLE_IOS(10_0);

- (void)cl_springTimingParametersWithDuration:(NSTimeInterval)duration
                                 dampingRatio:(CGFloat)dampingRatio
                                     velocity:(CGVector)velocity
                                   animations:(CLAnimatorManagerBlock)animations NS_AVAILABLE_IOS(10_0);

- (void)cl_springTimingParametersWithDuration:(NSTimeInterval)duration
                                 dampingRatio:(CGFloat)dampingRatio
                                     velocity:(CGVector)velocity
                                   animations:(CLAnimatorManagerBlock)animations
                                   completion:(CLAnimatorManagerCompleteBlock)completion NS_AVAILABLE_IOS(10_0);

- (void)cl_springTimingParametersWithDuration:(NSTimeInterval)duration
                                         mass:(CGFloat)mass
                                    stiffness:(CGFloat)stiffness
                                      damping:(CGFloat)damping
                                     velocity:(CGVector)velocity
                                   animations:(CLAnimatorManagerBlock)animations NS_AVAILABLE_IOS(10_0);

- (void)cl_springTimingParametersWithDuration:(NSTimeInterval)duration
                                         mass:(CGFloat)mass
                                    stiffness:(CGFloat)stiffness
                                      damping:(CGFloat)damping
                                     velocity:(CGVector)velocity
                                   animations:(CLAnimatorManagerBlock)animations
                                   completion:(CLAnimatorManagerCompleteBlock)completion NS_AVAILABLE_IOS(10_0);
複製代碼

UIViewPropertyAnimator

typedef void(^CLAnimatorManagerBlock)(void);
typedef void(^CLAnimatorManagerCompleteBlock)(UIViewAnimatingPosition finalPosition);
typedef void(^CLAnimatorManagerStatusBlock)(UIViewAnimatingState state);

@property (nonatomic, strong, readonly) UIViewPropertyAnimator *cl_viewPropertyAnimator;

- (void)cl_viewPropertyAnimatorWithDuration:(NSTimeInterval)duration
                           timingParameters:(id <UITimingCurveProvider>)parameters
                                 animations:(CLAnimatorManagerBlock)animations NS_AVAILABLE_IOS(10_0);

- (void)cl_viewPropertyAnimatorWithDuration:(NSTimeInterval)duration
                           timingParameters:(id <UITimingCurveProvider>)parameters
                                 animations:(CLAnimatorManagerBlock)animations
                                 completion:(CLAnimatorManagerCompleteBlock)completion NS_AVAILABLE_IOS(10_0);

- (void)cl_viewPropertyAnimatorWithDuration:(NSTimeInterval)duration
                                      curve:(UIViewAnimationCurve)curve
                                 animations:(CLAnimatorManagerBlock)animations NS_AVAILABLE_IOS(10_0);

- (void)cl_viewPropertyAnimatorWithDuration:(NSTimeInterval)duration
                                      curve:(UIViewAnimationCurve)curve
                                 animations:(CLAnimatorManagerBlock)animations
                                 completion:(CLAnimatorManagerCompleteBlock)completion NS_AVAILABLE_IOS(10_0);

- (void)cl_viewPropertyAnimatorWithDuration:(NSTimeInterval)duration
                              controlPoint1:(CGPoint)point1
                              controlPoint2:(CGPoint)point2
                                 animations:(CLAnimatorManagerBlock)animations NS_AVAILABLE_IOS(10_0);

- (void)cl_viewPropertyAnimatorWithDuration:(NSTimeInterval)duration
                              controlPoint1:(CGPoint)point1
                              controlPoint2:(CGPoint)point2
                                 animations:(CLAnimatorManagerBlock)animations
                                 completion:(CLAnimatorManagerCompleteBlock)completion NS_AVAILABLE_IOS(10_0);

- (void)cl_viewPropertyAnimatorWithDuration:(NSTimeInterval)duration
                               dampingRatio:(CGFloat)ratio
                                 animations:(CLAnimatorManagerBlock)animations NS_AVAILABLE_IOS(10_0);

- (void)cl_viewPropertyAnimatorWithDuration:(NSTimeInterval)duration
                               dampingRatio:(CGFloat)ratio
                                 animations:(CLAnimatorManagerBlock)animations
                                 completion:(CLAnimatorManagerCompleteBlock)completion NS_AVAILABLE_IOS(10_0);

- (void)cl_viewPropertyAnimatorWithDuration:(NSTimeInterval)duration
                                 afterDelay:(NSTimeInterval)delay
                                    options:(UIViewAnimationOptions)options
                                 animations:(CLAnimatorManagerBlock)animations
                                 completion:(CLAnimatorManagerCompleteBlock)completion NS_AVAILABLE_IOS(10_0);
複製代碼

UIViewPropertyAnimator控制相關

- (void)cl_starViewPropertyAnimator;

- (void)cl_starViewPropertyAnimatorAfterDelay:(NSTimeInterval)delay;

- (void)cl_pauseViewPropertyAnimator;

- (void)cl_stopViewPropertyAnimator:(BOOL)stop;

- (void)cl_finishViewPropertyAnimatorWithPosition:(UIViewAnimatingPosition)position;
複製代碼

CLButton@

CLButton是對系統UIButton的封裝並添加了一些特性:objective-c

typedef NS_ENUM(NSInteger, CLButtonStyle) {
    
    CLButtonImageTopStyle = 0,
    CLButtonImageLeftStyle,
    CLButtonImageBottomStyle,
    CLButtonImageRightStyle
};

@property (nonatomic, assign) CLButtonStyle cl_buttomImageStyle;
@property (nonatomic, assign) CGFloat cl_imageSpacing;
@property (nonatomic, assign) CGSize cl_imageSize;
複製代碼

CLCollectionViewController@

CLCollectionViewController是對系統UIViewController + UICollectionView的封裝並添加了一些特性:spring

- (void)cl_hiddenCollectionViewScrollIndicator;
複製代碼

UICollectionView與MJRefresh@

- (void)cl_removeRefresh;

- (void)cl_removeHeaderRefresh;

- (void)cl_removeFooterRefresh;

- (void)cl_dropDownRefresh;

- (void)cl_dropDownBeginRefresh;

- (void)cl_dropDownEndRefresh;

- (void)cl_pullUpRefresh;

- (void)cl_pullUpBeginRefresh;

- (void)cl_pullUpEndRefresh;

- (void)cl_endCollectionViewRefreshWithType:(CLCollectionViewRefreshType)refreshType;
複製代碼

UICollectionView代理與數據源@

- (void)cl_setCollectionViewDelegate:(_Nullable id <UICollectionViewDelegate>)delegate
                          dataSource:(_Nullable id <UICollectionViewDataSource>)dataSource;

- (void)cl_setCollectionViewDragDelegate:(_Nullable id <UICollectionViewDragDelegate>)dragDelegate
                            dropDelegate:(_Nullable id <UICollectionViewDropDelegate>)dropDelegate API_AVAILABLE(ios(11.0));
複製代碼

註冊類

- (void)cl_registerClass:(nullable Class)cellClass
              identifier:(NSString *)identifier;
複製代碼

CLCollectionViewDataSource@

CLCollectionViewDataSourceCLCollectionViewController的數據源, 須要配合着使用:網絡

@property (nonatomic, weak, readonly) CLCollectionViewViewModel *cl_viewModel;

- (instancetype)initCollectionViewDataSourceWithViewModel:(CLCollectionViewViewModel *)viewModel;
複製代碼

CLCollectionViewDelegate@

CLCollectionViewDelegateCLCollectionViewController的代理, 須要配合着使用:app

@property (nonatomic, weak, readonly) CLCollectionViewViewModel *cl_viewModel;

- (instancetype)initCollectionViewDelegateWithViewModel:(CLCollectionViewViewModel *)viewModel;
複製代碼

CLCollectionViewDragDelegate@

CLCollectionViewDragDelegateCLCollectionViewController的代理, 須要配合着使用:dom

@property (nonatomic, weak, readonly) CLCollectionViewViewModel *cl_viewModel;

- (instancetype)initCollectionViewDragDelegateWithViewModel:(CLCollectionViewViewModel *)viewModel;
複製代碼

CLCollectionViewDropDelegate@

CLCollectionViewDropDelegateCLCollectionViewController的代理, 須要配合着使用:

@property (nonatomic, weak, readonly) CLCollectionViewViewModel *cl_viewModel;

- (instancetype)initCollectionViewDropDelegateWithViewModel:(CLCollectionViewViewModel *)viewModel;
複製代碼

CLCollectionViewViewModel

CLCollectionViewViewModelCLCollectionViewControllerViewModel, 須要配合着使用:

@property (nonatomic, weak, readonly) CLCollectionViewController *cl_collectionViewController;

@property (nonatomic, strong) NSMutableArray *cl_dataSource;

- (instancetype)initCollectionViewBaseModelWithController:(CLCollectionViewController *)viewController;

- (void)cl_collectionViewHTTPRequest;
複製代碼

CLNavigationController@

CLNavigationController是針對系統UINavigationController的封裝並添加了一些特性:

@property (nonatomic, strong) UIImage *cl_backgroundImage;

@property (nonatomic, strong) UIColor *cl_tintColor;

@property (nonatomic, strong) UIColor *cl_foregroundColor;

@property (nonatomic, strong) UIImage *cl_shadowImage;
複製代碼

CLNavigationController默認重載了pushViewController:animated:, 會在pushViewController的時候自動隱藏掉UITarBar.

CLScanQRCodeController@

CLScanQRCodeController是基於AVFoundation進行封裝的QRCode掃描庫, 系統默認識別十三種編碼:

@property (nonatomic, strong) UIView *cl_scanQRCodeView;

@property (nonatomic, assign) BOOL cl_autoStopCaptureSessionRunning;

@property (nonatomic, weak) id <CLScanQRCodeControllerDelegate> cl_scanQRCodeControllerDelegate;

- (void)cl_startCaptureSessionRunning;

- (void)cl_stopCaptureSessionRunning;
複製代碼

獲取數據(Block)@

@property (nonatomic, copy) void(^cl_scanQRCodeGetMetadataObjectsBlock)(NSArray *metadataObjects);

@property (nonatomic, copy) void(^cl_scanQRCodeGetMetadataStringValue)(NSString *stringValue);
複製代碼

獲取數據(Delegate)@

- (void)cl_scanQRCodeGetMetadataObjectsWithMetadataObjects:(NSArray *)metadataObjects;

- (void)cl_scanQRCodeGetMetadataStringValue:(NSString *)stringValue;
複製代碼

CLScrollViewController@

CLScrollViewController是基於系統UIViewController+UIScrollView的封裝並添加了一些特性:

@property (nonatomic, strong, readonly) UIScrollView *cl_scrollView;

- (void)cl_hiddenScrollIndicator;
複製代碼

UIScrollView代理@

- (void)cl_setScrollViewDelegate:(_Nullable id <UIScrollViewDelegate>)delegate;
複製代碼

CLScrollViewViewModel

@property (nonatomic, weak, readonly) CLScrollViewController *cl_scrollViewController;

- (instancetype)initScrollViewDelegateWithController:(CLScrollViewController *)controller;
複製代碼

CLTableViewController@

CLTableViewController是針對系統UIViewController + UITableView的封裝並添加了一些特性:

@property (nonatomic, strong, null_resettable, readonly) UITableView *cl_tableView;

- (instancetype)initTableViewControllerWithStyle:(UITableViewStyle)style;

- (void)cl_hiddenTableViewScrollIndicator;
複製代碼

UITableView與MJRefresh@

- (void)cl_removeRefresh;

- (void)cl_removeHeaderRefresh;

- (void)cl_removeFooterRefresh;

- (void)cl_dropDownRefresh;

- (void)cl_dropDownBeginRefresh;

- (void)cl_dropDownEndRefresh;

- (void)cl_pullUpRefresh;

- (void)cl_pullUpBeginRefresh;

- (void)cl_pullUpEndRefresh;

- (void)cl_endTableViewRefreshWithType:(CLTableViewRefreshType)refreshType;
複製代碼

UITableView代理與數據源@

- (void)cl_setTableViewDelegate:(_Nullable id <UITableViewDelegate>)delegate
                     dataSource:(_Nullable id <UITableViewDataSource>)dataSource;

- (void)cl_setTableViewDragDelegate:(_Nullable id <UITableViewDragDelegate>)dragDelegate
                       dropDelegate:(_Nullable id <UITableViewDropDelegate>)dropDelegate API_AVAILABLE(ios(11.0));
複製代碼

CLTableViewDataSource@

CLTableViewDataSourceCLTableViewController的數據源, 須要配合着使用:

@property (nonatomic, weak, readonly) CLTableViewViewModel *cl_viewModel;

- (instancetype)initTableViewDataSourceWithViewModel:(CLTableViewViewModel *)viewModel;
複製代碼

CLTableViewDelegate@

CLTableViewDelegateCLTableViewController的代理, 須要配合着使用:

@property (nonatomic, weak, readonly) CLTableViewViewModel *cl_viewModel;

- (instancetype)initTableViewDelegateWithViewModel:(CLTableViewViewModel *)viewModel;
複製代碼

CLTableViewDragDelegate@

CLTableViewDragDelegateCLTableViewController的代理, 須要配合着使用:

@property (nonatomic, weak, readonly) CLTableViewViewModel *cl_viewModel;

- (instancetype)initTableViewDragDelegateWithViewModel:(CLTableViewViewModel *)viewModel;
複製代碼

CLTableViewDropDelegate@

CLTableViewDropDelegateCLTableViewController的代理, 須要配合着使用:

@property (nonatomic, weak, readonly) CLTableViewViewModel *cl_viewModel;

- (instancetype)initTableViewDropDelegateWithViewModel:(CLTableViewViewModel *)viewModel;
複製代碼

CLTableViewViewModel@

CLTableViewViewModelCLTableViewControllerViewModel, 須要配合着使用:

@property (nonatomic, strong) NSMutableArray *cl_dataSource;

@property (nonatomic, weak, readonly) CLTableViewController *cl_tableViewController;

- (instancetype)initTableViewBaseModelWithController:(CLTableViewController *)viewController;

- (void)cl_tableViewHTTPRequest;

- (void)cl_configTableViewWithDataSource;
複製代碼

關於CLTableViewController封裝的原理: 玩轉iOS開發:打造一個低耦合可複用的《TableViewController》.

CLTextField@

CLTextField是針對系統UITextField的封裝並添加了一些特性:

typedef NS_ENUM(NSInteger, CLTextFieldType) {
    
    CLTextFieldBottomNormal = 0, // default
    CLTextFieldBottomLineType
};

@property (nonatomic, assign) CLTextFieldType cl_textFieldType;

@property (nonatomic, strong) UIColor *cl_lineColor;
複製代碼

CLToolBarListView@

CLToolBarListView是在系統UIView上封裝的一個橫向菜單欄的控件(將來會重構一個更靈活的):

typedef NS_ENUM(NSInteger, CLToolBarStyle) {
    CLToolBarNormalStyle = 0,
    CLToolBarSeparationStyle
};

- (instancetype)initToolBarWithFrame:(CGRect)frame;

@property (nonatomic, assign) CLToolBarStyle cl_toolBarStyle;

@property (nonatomic, assign) BOOL cl_titleAdjustsFontSizeToFitWidth;

@property (nonatomic, strong) NSArray  *cl_titleArray;

@property (nonatomic, strong) UIColor *cl_selectedColor;

@property (nonatomic, strong) UIColor *cl_deselectColor;

@property (nonatomic, strong) UIColor *cl_barBakcgroundColor;

@property (nonatomic, strong) UIColor *cl_bottomLineColor;

@property (nonatomic, strong) UIColor *cl_selectedLineColor;

@property (nonatomic, assign) NSInteger cl_textFont;

@property (nonatomic, assign) CGFloat cl_buttonSpacing;

@property (nonatomic, assign) BOOL cl_isNeedLine;

@property (nonatomic, assign) BOOL cl_isNeedSelectedLine;

@property (nonatomic, getter=currentIndex) NSInteger cl_currentIndex;

#pragma mark - Tool Bar Separation Style Property
@property (nonatomic, strong) UIColor *cl_separationColor;

@property (nonatomic, assign) CGFloat cl_separationWidth;

#pragma mark - Common Method
- (void)cl_reloadData;

- (void)cl_didSelectedButton:(NSInteger)index;

@property (nonatomic, copy) void(^cl_toolBarSelectedBlock)(NSInteger index);
複製代碼

關於CLToolBarListView的用法, 之前就寫過一篇文章, 你們能夠去看看玩轉iOS開發:橫向滑動條《CLToolBarListView》.

CLViewController@

CLViewController是對系統UIViewController的封裝並添加了一些特性:

typedef NS_ENUM(NSInteger, CLViewControllerStyle) {
    
    CLMainViewController = 0, // Default
    CLChildViewController
};

- (instancetype)initCLViewControllerWith:(CLViewControllerStyle)style;
複製代碼

CLViewControllerViewModel@

CLViewControllerViewModel是對系統CLViewControllerViewModel, 須要配合使用:

@property (nonatomic, weak, readonly) CLViewController *cl_viewController;

- (instancetype)initViewControllerViewModelWithController:(CLViewController *)controller;
複製代碼

CLWebViewController@

CLWebViewController是對系統UIViewController + WKWebView的封裝並添加了一些特性:

@property (nonatomic, strong, readonly) WKWebView *cl_webView;

- (void)cl_setWebViewUIDelegate:(_Nullable id <WKUIDelegate>)UIDelegate
             navigationDelegate:(_Nullable id <WKNavigationDelegate>)navigationDelegate;
複製代碼

CLWebViewNavigationDelegate

CLWebViewNavigationDelegateCLWebViewControllerWKNavigationDelegate, 須要配合着使用:

@property (nonatomic, weak, readonly) CLWebViewViewModel *cl_viewModel;

- (instancetype)initWebViewNavigationDelegateWithViewModel:(CLWebViewViewModel *)viewModel;
複製代碼

CLWebViewUIDelegate

CLWebViewUIDelegateCLWebViewControllerUIDelegate, 須要配合着使用:

@property (nonatomic, weak, readonly) CLWebViewViewModel *cl_viewModel;

- (instancetype)initWebViewUIDelegateWithViewModel:(CLWebViewViewModel *)viewModel;
複製代碼

CLWebViewViewModel

CLWebViewViewModelCLWebViewControllerViewModel, 須要配合着使用:

@property (nonatomic, weak, readonly) CLWebViewController *cl_webViewController;

- (instancetype)initWebViewModelWithController:(CLWebViewController *)controller;
複製代碼

UIApplication+CLApplication@

針對UIKitUIApplication進行系統外的方法補充:

+ (BOOL)cl_getApplicationLocationPermit;

+ (BOOL)cl_getApplicationAddressBookPermit;

+ (BOOL)cl_getApplicationCameraPermit;

+ (BOOL)cl_getApplicationRemindersPermit;

+ (BOOL)cl_getApplicationPhotosLibraryPermit;

+ (void)cl_getApplicationMicrophonePermitWithBlock:(CLPermissionBlock)block;

+ (void)cl_callPhoneWithPhoneNumber:(NSString *)phoneNumber;

+ (void)cl_sendEmailWithEmailAddress:(NSString *)emailAddress;

+ (void)cl_goToAppSetting;

+ (UIImage *)cl_getApplicationLaunchImage;

+ (CGFloat)cl_getStatusBarHeight;
複製代碼

UIButton+CLButton@

針對UIKitUIButton進行系統外的方法補充:

typedef NS_ENUM(NSInteger, CLButtonStarStyle) {
    CLButtonStarStyleBegin = 0,
    CLButtonStarStyleFinish
};

typedef void(^CLButtonStar)(UIButton *cl_starButton, CLButtonStarStyle cl_buttonStarStyle, NSInteger time);

typedef void (^CLButtonAction)(UIButton *sender);

@interface UIButton (CLButton)

@property (nonatomic, assign) UIEdgeInsets cl_clickAreaEdgeInsets;

@property (nonatomic, assign, readonly) BOOL cl_isSubmitting;

#pragma mark - 倒計時方法
- (void)cl_starButtonWithTime:(NSInteger)time
                     complete:(CLButtonStar)complete;

#pragma mark - 添加UIButton點擊方法
- (void)cl_addButtonActionComplete:(CLButtonAction)complete;

#pragma mark - 用UIActivityIndicatorView代替文字
- (void)cl_showActivityIndicatorViewWithStyle:(UIActivityIndicatorViewStyle)style;

- (void)cl_hideActivityIndicatorView;

#pragma mark - 設置UIButton圖片
- (void)cl_setNormalButtonWithImage:(UIImage *)image;

- (void)cl_setNormalButtonImageWithColor:(UIColor *)color;

- (void)cl_setHighlightedButtonWithImage:(UIImage *)image;

- (void)cl_setHighlightedButtonImageWithColor:(UIColor *)color;

- (void)cl_setSelectedButtonWithImage:(UIImage *)image;

- (void)cl_setSelectedButtonImageWithColor:(UIColor *)color;

- (void)cl_setDisabledButtonWithImage:(UIImage *)image;

- (void)cl_setDisabledButtonImageWithColor:(UIColor *)color;

#pragma mark - 設置UIButton背景圖片
- (void)cl_setNormalButtonBackgroundImageWithImage:(UIImage *)image;

- (void)cl_setHighlightedButtonBackgroundImageWithImage:(UIImage *)image;

- (void)cl_setSelectedButtonBackgroundImageWithImage:(UIImage *)image;

- (void)cl_setDisabledButtonBackgroundImageWithImage:(UIImage *)image;

#pragma mark - 獲取UIButton的圖片
- (UIImage *)cl_getNormalButtonImage;

- (UIImage *)cl_getHighlightedButtonImage;

- (UIImage *)cl_getSelectedButtonImage;

- (UIImage *)cl_getDisabledButtonImage;

#pragma mark - 獲取UIButton的背景圖片
- (UIImage *)cl_getNormalButtonBackgroundImage;

- (UIImage *)cl_getHighlightedButtonBackgroundImage;

- (UIImage *)cl_getSelectedButtonBackgroundImage;

- (UIImage *)cl_getDisabledButtonBackgroundImage;

#pragma mark - 設置UIButton標題
- (void)cl_setNormalButtonWithTitle:(NSString *)title;

- (void)cl_setHighlightedButtonWithTitle:(NSString *)title;

- (void)cl_setSelectedButtonWithTitle:(NSString *)title;

- (void)cl_setDisabledButtonWithTitle:(NSString *)title;

#pragma mark - 獲取UIButton標題
- (NSString *)cl_getNormalButtonTitle;

- (NSString *)cl_getHighlightedButtonTitle;

- (NSString *)cl_getSelectedButtonTitle;

- (NSString *)cl_getDisabledButtonTitle;

#pragma mark - 設置UIButton標題
- (void)cl_setNormalTitleWithColor:(UIColor *)color;

- (void)cl_setHighlightedTitleWithColor:(UIColor *)color;

- (void)cl_setSelectedTitleWithColor:(UIColor *)color;

- (void)cl_setDisabledTitleWithColor:(UIColor *)color;

#pragma mark - 獲取UIButton標題顏色
- (UIColor *)cl_getNormalButtonTitleColor;

- (UIColor *)cl_getHighlightedButtonTitleColor;

- (UIColor *)cl_getSelectedButtonTitleColor;

- (UIColor *)cl_getDisabledButtonTitleColor;

#pragma mark - 設置UIButton的NSAttributedString標題
- (void)cl_setNormalButtonWithAttributedStringTitle:(NSAttributedString *)attributedString;

- (void)cl_setHighlightedButtonWithAttributedStringTitle:(NSAttributedString *)attributedString;

- (void)cl_setSelectedButtonWithAttributedStringTitle:(NSAttributedString *)attributedString;

- (void)cl_setDisabledButtonWithAttributedStringTitle:(NSAttributedString *)attributedString;

#pragma mark - 獲取UIButton標題
- (NSAttributedString *)cl_getNormalButtonAttributedStringTitle;

- (NSAttributedString *)cl_getHighlightedButtonAttributedStringTitle;

- (NSAttributedString *)cl_getSelectedButtonAttributedStringTitle;

- (NSAttributedString *)cl_getDisabledButtonAttributedStringTitle;
複製代碼

UICollectionView+CLCollectionView@

針對UIKitUICollectionView進行系統外的方法補充:

UICollectionView佔位圖代理@

@protocol CLCollectionViewPlaceholderDelegate <NSObject>

@required

- (UIView *)cl_placeholderView;

@optional

- (BOOL)cl_scrollEnabledWithShowPlaceholderView;

@end
複製代碼

UICollectionView刷新@

- (void)cl_reloadData;

- (void)cl_removePlaceholderViewWithSuperView;
複製代碼

UIColor+CLColor@

針對UIKitUIColor進行系統外的方法補充:

+ (UIColor *)cl_getARC4RandomColor;

+ (UIColor *)cl_colorWithHex:(NSInteger)hexValue;

+ (UIColor *)cl_colorWithHex:(NSInteger)hexValue
                       alpha:(CGFloat)alphaValue;

+ (UIColor *)cl_colorWithHexString:(NSString *)hexString;

+ (UIColor *)cl_colorWithHexString:(NSString *)hexString
                             alpha:(CGFloat)alphaValue;

+ (UIColor *)cl_colorWithRed:(CGFloat)red
                       green:(CGFloat)green
                        blue:(CGFloat)blue
                       alpha:(CGFloat)alpha;

+ (UIColor *)cl_colorWithRed:(CGFloat)red
                       green:(CGFloat)green
                        blue:(CGFloat)blue;

+ (UIColor *)cl_configGradientWithBeginColor:(UIColor *)beginColor
                                    endColor:(UIColor *)endColor
                                      height:(CGFloat)height;
複製代碼

UIControl+CLControl@

針對UIKitUIControl進行系統外的方法補充:

typedef void(^CLControlAction)(id sender);

@interface CLControlActionBlockObject : NSObject

@property (nonatomic, copy) CLControlAction cl_controlAction;

@property (nonatomic, assign) UIControlEvents cl_controlEvents;

- (void)cl_controlInvokeBlock:(id)sender;

@end

@interface UIControl (CLControl)

- (void)cl_addControlActionWithEvents:(UIControlEvents)controlEvents
                             complete:(CLControlAction)complete;

- (void)cl_setControlActionWithEvents:(UIControlEvents)controlEvents
                             complete:(CLControlAction)complete;

- (void)cl_removeControlActionWithEvents:(UIControlEvents)controlEvents;

- (void)cl_removeAllActions;

@end
複製代碼

UIDevice+CLDevice@

針對UIKitUIDevice進行系統外的方法補充:

設備相關@

+ (NSString *)cl_getSystemVersion;

+ (NSString *)cl_getDeviceName;

+ (NSString *)cl_getDeviceModelType;

+ (NSString *)cl_getUUIDString;

+ (NSString *)cl_getCurrentDeviceModelName;

+ (BOOL)cl_isPad;

+ (BOOL)cl_isSimulator;

+ (BOOL)cl_isJailbroken;
複製代碼

CPU相關@

+ (NSUInteger)cl_getCurrentDeviceCPUCount;

+ (CGFloat)cl_getCurrentDeviceAllCoreCPUUse;

+ (NSArray *)cl_getCurrentDeviceSingleCoreCPUUse;
複製代碼

網絡相關@

+ (NSString *)cl_getCarrierName;

+ (NSString *)cl_getCurrentRadioAccessTechnology;

+ (NSString *)cl_getCurrentDeviceIPAddresses;

+ (NSString *)cl_getCurrentDeviceIPAddressWithWiFi;

+ (NSString *)cl_getCurrentDeviceIPAddressWithCell;
複製代碼

存儲相關@

+ (int64_t)cl_getDiskSpace;

+ (int64_t)cl_getDiskSpaceFree;

+ (int64_t)cl_getDiskSpaceUsed;
複製代碼

內存相關@

+ (int64_t)cl_getMemoryTotal;

+ (int64_t)cl_getMemoryFree;

+ (int64_t)cl_getMemoryActive;

+ (int64_t)cl_getMemoryInactive;

+ (int64_t)cl_getMemoryWired;

+ (int64_t)cl_getMemoryPurgable;
複製代碼

UIFont+CLFont@

針對UIKitUIFont進行系統外的方法補充:

+ (UIFont *)cl_fitSystemFontOfSize:(CGFloat)fontSize;

+ (UIFont *)cl_fitBoldSystemFontOfSize:(CGFloat)fontSize;

+ (UIFont *)cl_fitItalicSystemFontOfSize:(CGFloat)fontSize;

+ (UIFont *)cl_fitSystemFontOfSize:(CGFloat)fontSize
                            weight:(UIFontWeight)weight NS_AVAILABLE_IOS(8_2);

+ (UIFont *)cl_fitMonospacedDigitSystemFontOfSize:(CGFloat)fontSize
                                           weight:(UIFontWeight)weight NS_AVAILABLE_IOS(9_0);

+ (BOOL)cl_loadFontWithPath:(NSString *)path;

+ (void)cl_unloadFontWithPath:(NSString *)path;

+ (UIFont *)cl_loadFontWithData:(NSData *)data;

+ (BOOL)cl_unloadFontWithData:(UIFont *)font;

+ (UIFont *)cl_fitCustomFontWithName:(NSString *)name
                            fontSize:(CGFloat)fontSize;
複製代碼

UIImage+CLImage@

針對UIKitUIImage進行系統外的方法補充:

生成指定顏色的圖片@

+ (void)cl_asyncGetImageWithColor:(UIColor *)color
                       completion:(CLImage)completion;

+ (void)cl_asyncGetImageWithColor:(UIColor *)color
                             rect:(CGRect)rect
                       completion:(CLImage)completion;

+ (void)cl_asyncGetImageWithColor:(UIColor *)color
                           radius:(CGFloat)radius
                       completion:(CLImage)completion;

+ (void)cl_asyncGetImageWithColor:(UIColor *)color
                             rect:(CGRect)rect
                           radius:(CGFloat)radius
                       completion:(CLImage)completion;
複製代碼

截取指定視圖大小的截圖@

+ (UIImage *)cl_getImageForView:(UIView *)view;
複製代碼

縮放指定比例的圖片@

+ (void)cl_asyncDrawImageToSize:(CGSize)size
                          image:(UIImage *)image
                     completion:(CLImage)completion;
複製代碼

加載GIF圖片@

+ (void)cl_asyncLoadGIFImageForName:(NSString *)name
                         completion:(CLImage)completion;

+ (void)cl_asyncLoadGIFImageWithData:(NSData *)data
                          completion:(CLImage)completion;

+ (BOOL)cl_isAnimatedGIFWithData:(NSData *)data;

+ (BOOL)cl_isAnimatedGIFWithFilePath:(NSString *)filePath;
複製代碼

生成二維碼@

+ (void)cl_asyncCreateQRCodeImageWithString:(NSString *)string
                                 completion:(CLImage)completion;

+ (void)cl_asyncCreateQRCodeImageWithString:(NSString *)string
                                  logoImage:(UIImage *)logoImage
                                 completion:(CLImage)completion;
複製代碼

生成條形碼@

+ (void)cl_asyncCreate128BarcodeImageWithString:(NSString *)string
                                     completion:(CLImage)completion;

+ (void)cl_asyncCreate128BarcodeImageWithString:(NSString *)string
                                     imageSpace:(CGFloat)imageSpace
                                     completion:(CLImage)completion;
複製代碼

獲取圖片@

+ (UIImage *)cl_getImageWithBundleName:(NSString *)bundle
                             imageName:(NSString *)imageName;

+ (void)cl_asyncGetVideoPreViewImageWithVideoURL:(NSURL *)videoURL
                                      completion:(CLImage)completion;
複製代碼

圖片高斯模糊處理@

+ (void)cl_asyncBlurImageWithBlur:(CGFloat)blur
                            image:(UIImage *)image
                       completion:(CLImage)completion;
複製代碼

圖片圓角處理@

+ (void)cl_asyncCornerImageWithRadius:(CGFloat)radius
                                image:(UIImage *)image
                           completion:(CLImage)completion;

+ (void)cl_asyncCornerImageWithRadius:(CGFloat)radius
                                image:(UIImage *)image
                          borderWidth:(CGFloat)borderWidth
                          borderColor:(UIColor *)borderColor
                           completion:(CLImage)completion;
複製代碼

圖片處理

+ (void)cl_resetSizeWithImage:(UIImage *)image
                         size:(CGSize)size
                   completion:(CLImage)completion;

+ (CGSize)cl_getScaleImageWithImage:(UIImage *)image
                             length:(CGFloat)length;
複製代碼

UINavigationController+CLNavigationController

針對UIKitUINavigationController進行系統外的方法補充:

- (UIViewController *)cl_findViewControllerWithClassName:(NSString *)className;

- (NSUInteger)cl_getIndexWithViewController:(UIViewController *)viewController;

- (UIViewController *)cl_getFirstViewController;

- (NSArray *)cl_popToViewControllerWithClassName:(NSString *)className
                                        animated:(BOOL)animated;

- (NSArray *)cl_popToViewControllerWithLevel:(NSUInteger)level
                                    animated:(BOOL)animated;

- (CGFloat)cl_getNavigationBarHeight;
複製代碼

UINavigationItem+CLNavigationItem@

針對UIKitUINavigationItem進行系統外的方法補充:

這裏沒有提供外部的API, 內部實如今iOS 11以前修改UINavigationBar backItem的標題, 若是不須要修改的話, 請在CLUIKit.h文件註釋#import "UINavigationItem+CLNavigationItem.h"

UIScreen+CLScreen@

針對UIKitUIScreen進行系統外的方法補充:

+ (CGFloat)cl_getScreenScale;

+ (CGSize)cl_getScreenSize;

+ (CGRect)cl_getCurrentScreenBounds;

+ (CGFloat)cl_getScreenWidth;

+ (CGFloat)cl_getScreenHeight;

+ (CGFloat)cl_fitScreen:(CGFloat)value;

+ (CGFloat)cl_getStatusBarHeight;

+ (CGFloat)cl_getNavigationBarHeight;

+ (CGFloat)cl_getTabBarHeight;
複製代碼

UIScrollView+CLScrollView

針對UIKitUIScrollView進行系統外的方法補充:

- (void)cl_scrollViewToTopWithAnimated:(BOOL)animated;

- (void)cl_scrollViewToLeftWithAnimated:(BOOL)animated;

- (void)cl_scrollViewToBottomWithAnimated:(BOOL)animated;

- (void)cl_scrollViewToRightWithAnimated:(BOOL)animated;
複製代碼

UITableView+CLTableView@

針對UIKitUITableView進行系統外的方法補充:

UITableView+CLTableView佔位代理@

@protocol CLTableViewPlaceholderDelegate <NSObject>

@required

- (UIView *)cl_placeholderView;

@optional

- (BOOL)cl_calculateTableViewHeaderViewFrame;

- (BOOL)cl_scrollEnabledWithShowPlaceholderView;

@end

- (void)cl_removePlaceholderViewWithSuperView;
複製代碼

UITableView+CLTableView刷新@

typedef void(^CLTableViewUpdateBlock)(UITableView *tableView);

- (void)cl_reloadData;


- (void)cl_updateTableViewWithComplete:(CLTableViewUpdateBlock)complete;

- (void)cl_reloadRowWithIndexPath:(NSIndexPath *)indexPath
                        animation:(UITableViewRowAnimation)animation;

- (void)cl_reloadWithSection:(NSUInteger)section
                   animation:(UITableViewRowAnimation)animation;

- (void)cl_reloadWithRow:(NSUInteger)row
                 section:(NSUInteger)section
               animation:(UITableViewRowAnimation)animation;
複製代碼

UITableView+CLTableView顯示IndexPath

- (void)cl_scrollToIndexPath:(NSIndexPath *)indexPath
              scrollPosition:(UITableViewScrollPosition)scrollPosition
                    animated:(BOOL)animated;

- (void)cl_scrollToRow:(NSUInteger)row
               section:(NSUInteger)section
        scrollPosition:(UITableViewScrollPosition)scrollPosition
              animated:(BOOL)animated;
複製代碼

UITableView+CLTableView插入IndexPath@

- (void)cl_insertRowWithIndexPath:(NSIndexPath *)indexPath
                        animation:(UITableViewRowAnimation)animation;

- (void)cl_insertWithSection:(NSUInteger)section
                   animation:(UITableViewRowAnimation)animation;

- (void)cl_insertWithRow:(NSUInteger)row
                 section:(NSUInteger)section
               animation:(UITableViewRowAnimation)animation;

複製代碼

UITableView+CLTableView刪除IndexPath@

- (void)cl_deleteRowWithIndexPath:(NSIndexPath *)indexPath
                        animation:(UITableViewRowAnimation)animation;

- (void)cl_deleteWithSection:(NSUInteger)section
                   animation:(UITableViewRowAnimation)animation;

- (void)cl_deleteWithRow:(NSUInteger)row
                 section:(NSUInteger)section
               animation:(UITableViewRowAnimation)animation;

- (void)cl_resetSelectedRowsAnimated:(BOOL)animated;
複製代碼

UIView+CLView@

針對UIKitUIView進行系統外的方法補充:

內部實如今iOS 11修改UINavigationBar backItem的標題, 若是不須要修改的話, 請在CLUIKit.h文件註釋#import "UIView+CLView.h"

typedef void (^CLGestureActionBlock)(UIGestureRecognizer *gestureRecoginzer);

@property (nonatomic, assign) CGSize cl_size;

@property (nonatomic, assign) CGFloat cl_width;
@property (nonatomic, assign) CGFloat cl_height;
@property (nonatomic, assign) CGFloat cl_top;
@property (nonatomic, assign) CGFloat cl_left;
@property (nonatomic, assign) CGFloat cl_bottom;
@property (nonatomic, assign) CGFloat cl_right;
@property (nonatomic, assign) CGFloat cl_centerX;
@property (nonatomic, assign) CGFloat cl_centerY;

- (void)cl_addTapGestureRecognizerWithBlock:(CLGestureActionBlock)block;

- (void)cl_addLongPressGestureRecognizerWithBlock:(CLGestureActionBlock)block;

- (id)cl_getSubViewWithSubViewClass:(Class)objcClass;

- (id)cl_getSuperViewWithSuperViewClass:(Class)objcClass;

- (BOOL)cl_resignFirstResponder;

- (UIView *)cl_getFirstResponder;

複製代碼

UIViewController+CLViewController@

針對UIKitUIViewController進行系統外的方法補充:

UIViewControllerBackItem檢測代理@

@protocol CLNavigationControllerBackItemProtocol <NSObject>
@optional

- (BOOL)cl_navigationShouldPopOnBackButton;

@end
複製代碼

UIViewController+CLViewController方法@

- (BOOL)cl_navigationShouldPopOnBackButton;

- (void)cl_setNavigationBarTranslucentWithBOOL:(BOOL)bools;

- (void)cl_setTabBarTranslucentWithBOOL:(BOOL)bools;

#pragma mark - 呼叫手機
- (void)cl_callPhoneWithPhoneNumber:(NSString *)phoneNumber
                            message:(NSString *)message
                             titile:(NSString *)title;

#pragma mark - UIAlertController自定義
- (void)cl_showAlertViewControllerWithTitle:(NSString *)title
                                    message:(NSString *)message
                                buttonTitle:(NSString *)buttonTitle;

- (void)cl_showSheetViewControllerWithTitle:(NSString *)title
                                    message:(NSString *)message
                               actionTitles:(NSArray<NSString *> *)actionTitles
                                   complete:(CLAlertControlAction)complete;

- (void)cl_showAlertViewControllerWithTitle:(NSString *)title
                                    message:(NSString *)message
                               actionTitles:(NSArray<NSString *> *)actionTitles
                                   complete:(CLAlertControlAction)complete;

- (void)cl_showAlertViewControllerWithTitle:(NSString *)title
                                    message:(NSString *)message
                                    actions:(NSArray<UIAlertAction *> *)actions
                             preferredStyle:(UIAlertControllerStyle)preferredStyle;
複製代碼
相關文章
相關標籤/搜索