CainLuo / CLUIKit

MIT License
27 stars 4 forks source link

CLUIKit

CocoaPods Compatible Carthage Compatible Platform Language

CLUIKit简介

CLUIKit是对系统UIKit API进行扩展, 以及一些自己封装的UI, API的用法全部都在CLUIKitExample里, 如果在使用库遇到的一些疑惑欢迎随时Issues给我.

支持CocoaPod管理

pod 'CLUIKit'

支助

如果您觉得挺赞的话, 可以给我打赏打赏, 谢谢啦~

支付宝

目录

CLAnimatorManager

CLAnimatorManager是针对系统的UIViewPropertyAnimator封装的一个类库, 只支持iOS 10之后的系统.

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的封装并添加了一些特性:

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的封装并添加了一些特性:

- (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的代理, 需要配合着使用:

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

- (instancetype)initCollectionViewDelegateWithViewModel:(CLCollectionViewViewModel *)viewModel;

CLCollectionViewDragDelegate@

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

@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;