CLUIKit
是对系统UIKit API
进行扩展, 以及一些自己封装的UI
, API
的用法全部都在CLUIKitExample
里, 如果在使用库遇到的一些疑惑欢迎随时Issues
给我.
支持CocoaPod
管理
pod 'CLUIKit'
如果您觉得挺赞的话, 可以给我打赏打赏, 谢谢啦~
CLAnimatorManager
是针对系统的UIViewPropertyAnimator
封装的一个类库, 只支持iOS 10
之后的系统.
- (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);
- (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);
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);
- (void)cl_starViewPropertyAnimator;
- (void)cl_starViewPropertyAnimatorAfterDelay:(NSTimeInterval)delay;
- (void)cl_pauseViewPropertyAnimator;
- (void)cl_stopViewPropertyAnimator:(BOOL)stop;
- (void)cl_finishViewPropertyAnimatorWithPosition:(UIViewAnimatingPosition)position;
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
是对系统UIViewController + UICollectionView
的封装并添加了一些特性:
- (void)cl_hiddenCollectionViewScrollIndicator;
- (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;
- (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
是CLCollectionViewController
的数据源, 需要配合着使用:
@property (nonatomic, weak, readonly) CLCollectionViewViewModel *cl_viewModel;
- (instancetype)initCollectionViewDataSourceWithViewModel:(CLCollectionViewViewModel *)viewModel;
CLCollectionViewDelegate
是CLCollectionViewController
的代理, 需要配合着使用:
@property (nonatomic, weak, readonly) CLCollectionViewViewModel *cl_viewModel;
- (instancetype)initCollectionViewDelegateWithViewModel:(CLCollectionViewViewModel *)viewModel;
CLCollectionViewDragDelegate
是CLCollectionViewController
的代理, 需要配合着使用:
@property (nonatomic, weak, readonly) CLCollectionViewViewModel *cl_viewModel;
- (instancetype)initCollectionViewDragDelegateWithViewModel:(CLCollectionViewViewModel *)viewModel;
CLCollectionViewDropDelegate
是CLCollectionViewController
的代理, 需要配合着使用:
@property (nonatomic, weak, readonly) CLCollectionViewViewModel *cl_viewModel;
- (instancetype)initCollectionViewDropDelegateWithViewModel:(CLCollectionViewViewModel *)viewModel;
CLCollectionViewViewModel
是CLCollectionViewController
的ViewModel
, 需要配合着使用:
@property (nonatomic, weak, readonly) CLCollectionViewController *cl_collectionViewController;
@property (nonatomic, strong) NSMutableArray *cl_dataSource;
- (instancetype)initCollectionViewBaseModelWithController:(CLCollectionViewController *)viewController;
- (void)cl_collectionViewHTTPRequest;
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
是基于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;
@property (nonatomic, copy) void(^cl_scanQRCodeGetMetadataObjectsBlock)(NSArray *metadataObjects);
@property (nonatomic, copy) void(^cl_scanQRCodeGetMetadataStringValue)(NSString *stringValue);
- (void)cl_scanQRCodeGetMetadataObjectsWithMetadataObjects:(NSArray *)metadataObjects;
- (void)cl_scanQRCodeGetMetadataStringValue:(NSString *)stringValue;
CLScrollViewController
是基于系统UIViewController+UIScrollView
的封装并添加了一些特性:
@property (nonatomic, strong, readonly) UIScrollView *cl_scrollView;
- (void)cl_hiddenScrollIndicator;
- (void)cl_setScrollViewDelegate:(_Nullable id <UIScrollViewDelegate>)delegate;
@property (nonatomic, weak, readonly) CLScrollViewController *cl_scrollViewController;
- (instancetype)initScrollViewDelegateWithController:(CLScrollViewController *)controller;
CLTableViewController
是针对系统UIViewController + UITableView
的封装并添加了一些特性:
@property (nonatomic, strong, null_resettable, readonly) UITableView *cl_tableView;
- (instancetype)initTableViewControllerWithStyle:(UITableViewStyle)style;
- (void)cl_hiddenTableViewScrollIndicator;
- (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;
- (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
是CLTableViewController
的数据源, 需要配合着使用:
@property (nonatomic, weak, readonly) CLTableViewViewModel *cl_viewModel;
- (instancetype)initTableViewDataSourceWithViewModel:(CLTableViewViewModel *)viewModel;
CLTableViewDelegate
是CLTableViewController
的代理, 需要配合着使用:
@property (nonatomic, weak, readonly) CLTableViewViewModel *cl_viewModel;
- (instancetype)initTableViewDelegateWithViewModel:(CLTableViewViewModel *)viewModel;
CLTableViewDragDelegate
是CLTableViewController
的代理, 需要配合着使用:
@property (nonatomic, weak, readonly) CLTableViewViewModel *cl_viewModel;
- (instancetype)initTableViewDragDelegateWithViewModel:(CLTableViewViewModel *)viewModel;
CLTableViewDropDelegate
是CLTableViewController
的代理, 需要配合着使用:
@property (nonatomic, weak, readonly) CLTableViewViewModel *cl_viewModel;
- (instancetype)initTableViewDropDelegateWithViewModel:(CLTableViewViewModel *)viewModel;
CLTableViewViewModel
是CLTableViewController
的ViewModel
, 需要配合着使用:
@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
是针对系统UITextField
的封装并添加了一些特性:
typedef NS_ENUM(NSInteger, CLTextFieldType) {
CLTextFieldBottomNormal = 0, // default
CLTextFieldBottomLineType
};
@property (nonatomic, assign) CLTextFieldType cl_textFieldType;
@property (nonatomic, strong) UIColor *cl_lineColor;
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
是对系统UIViewController
的封装并添加了一些特性:
typedef NS_ENUM(NSInteger, CLViewControllerStyle) {
CLMainViewController = 0, // Default
CLChildViewController
};
- (instancetype)initCLViewControllerWith:(CLViewControllerStyle)style;
CLViewControllerViewModel
是对系统CLViewController
的ViewModel
, 需要配合使用:
@property (nonatomic, weak, readonly) CLViewController *cl_viewController;
- (instancetype)initViewControllerViewModelWithController:(CLViewController *)controller;
CLWebViewController
是对系统UIViewController
+ WKWebView
的封装并添加了一些特性:
@property (nonatomic, strong, readonly) WKWebView *cl_webView;
- (void)cl_setWebViewUIDelegate:(_Nullable id <WKUIDelegate>)UIDelegate
navigationDelegate:(_Nullable id <WKNavigationDelegate>)navigationDelegate;
CLWebViewNavigationDelegate
是CLWebViewController
的WKNavigationDelegate
, 需要配合着使用:
@property (nonatomic, weak, readonly) CLWebViewViewModel *cl_viewModel;
- (instancetype)initWebViewNavigationDelegateWithViewModel:(CLWebViewViewModel *)viewModel;
CLWebViewUIDelegate
是CLWebViewController
的UIDelegate
, 需要配合着使用:
@property (nonatomic, weak, readonly) CLWebViewViewModel *cl_viewModel;
- (instancetype)initWebViewUIDelegateWithViewModel:(CLWebViewViewModel *)viewModel;
CLWebViewViewModel
是CLWebViewController
的ViewModel
, 需要配合着使用:
@property (nonatomic, weak, readonly) CLWebViewController *cl_webViewController;
- (instancetype)initWebViewModelWithController:(CLWebViewController *)controller;
针对UIKit
的UIApplication
进行系统外的方法补充:
+ (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;
针对UIKit
的UIButton
进行系统外的方法补充:
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;
针对UIKit
的UICollectionView
进行系统外的方法补充:
@protocol CLCollectionViewPlaceholderDelegate <NSObject>
@required
- (UIView *)cl_placeholderView;
@optional
- (BOOL)cl_scrollEnabledWithShowPlaceholderView;
@end
- (void)cl_reloadData;
- (void)cl_removePlaceholderViewWithSuperView;
针对UIKit
的UIColor
进行系统外的方法补充:
+ (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;
针对UIKit
的UIControl
进行系统外的方法补充:
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
针对UIKit
的UIDevice
进行系统外的方法补充:
+ (NSString *)cl_getSystemVersion;
+ (NSString *)cl_getDeviceName;
+ (NSString *)cl_getDeviceModelType;
+ (NSString *)cl_getUUIDString;
+ (NSString *)cl_getCurrentDeviceModelName;
+ (BOOL)cl_isPad;
+ (BOOL)cl_isSimulator;
+ (BOOL)cl_isJailbroken;
+ (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;
针对UIKit
的UIFont
进行系统外的方法补充:
+ (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;
针对UIKit
的UIImage
进行系统外的方法补充:
+ (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;
+ (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;
针对UIKit
的UINavigationController
进行系统外的方法补充:
- (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;
针对UIKit
的UINavigationItem
进行系统外的方法补充:
这里没有提供外部的API, 内部实现在iOS 11之前修改UINavigationBar backItem的标题, 如果不需要修改的话, 请在CLUIKit.h文件注释#import "UINavigationItem+CLNavigationItem.h"
针对UIKit
的UIScreen
进行系统外的方法补充:
+ (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;
针对UIKit
的UIScrollView
进行系统外的方法补充:
- (void)cl_scrollViewToTopWithAnimated:(BOOL)animated;
- (void)cl_scrollViewToLeftWithAnimated:(BOOL)animated;
- (void)cl_scrollViewToBottomWithAnimated:(BOOL)animated;
- (void)cl_scrollViewToRightWithAnimated:(BOOL)animated;
针对UIKit
的UITableView
进行系统外的方法补充:
@protocol CLTableViewPlaceholderDelegate <NSObject>
@required
- (UIView *)cl_placeholderView;
@optional
- (BOOL)cl_calculateTableViewHeaderViewFrame;
- (BOOL)cl_scrollEnabledWithShowPlaceholderView;
@end
- (void)cl_removePlaceholderViewWithSuperView;
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;
- (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;
- (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;
- (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;
针对UIKit
的UIView
进行系统外的方法补充:
内部实现在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;
针对UIKit
的UIViewController
进行系统外的方法补充:
@protocol CLNavigationControllerBackItemProtocol <NSObject>
@optional
- (BOOL)cl_navigationShouldPopOnBackButton;
@end
- (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;