iOS 福利來了,方便開發的工具庫集合 前言

前言

  • 花了半天時間整理我平時用的工具庫,詳細介紹每個方法屬性
  • 機器貓工具庫,就像機器貓的口袋一樣有無窮無盡意想不到的的各種道具供我們使用
    | |
    |:-|

功能介紹

本庫主要包含幾大板塊:UIKit類、Foundation類、Language 多語言類、Classes 粒子效果相關、Control 自定義控件

  • UIButton:圖文混排、點擊事件封裝、擴大點擊域、時間間隔限制、倒計時、點擊粒子效果等
  • UIView:手勢封裝、圓角漸變、Xib屬性,基礎動畫封裝等
  • UITextView:輸入框擴展、限制字數、撤銷處理、獲取文本內部超鏈接
  • UITextField:佔位顏色,線條,圖文處理等
  • UILabel:富文本,快捷顯示文本位置
  • UIImage:截圖和裁剪、圖片壓縮、蒙版處理,圖片拼接、圖片尺寸處理,濾鏡渲染、泛洪算法等
  • UIImage:二維碼、條形碼生成,動態圖播放,水印處理等等
  • Runtime:列表,方法交換,動態繼承等
  • UIDevice:系統相關屬性,
  • Language:多語言,支持Xib快捷設置
  • Foundation:數組和字典防崩處理,數組算法處理,謂詞相關,加密解密等等
  • 圖片處理封裝,霍夫矯正,特徵提取,形態學處理,濾鏡處理等等

Foundation我還整理封裝異常處理Crash防護 KJExceptionDemo

<a id="Cocoapods安裝"></a>Cocoapods安裝

UIKit模塊安裝

pod 'KJEmitterView'

Foundation模塊安裝

pod 'KJEmitterView/Foundation'

多語音模塊

pod 'KJEmitterView/Language' # 多語言

Opencv圖片模塊

該模塊需要引入OpenCV庫

pod 'OpenCV', '~> 4.1.0'
pod 'KJEmitterView/Opencv'   # 圖片處理

粒子效果模塊

pod 'KJEmitterView/Classes'  # 粒子效果相關

自定義控件模塊

pod 'KJEmitterView/Control'  # 自定義控件

目錄

關於類型說明

Property:屬性
Class & Property:類屬性
Protocol:協議
Instance:實例方法
Class:類方法
Function:函數

<a id="UIView"></a>UIView

UIView+KJAnimation 簡單動畫效果鏈式封裝

功能 類型 API & Property
隱式動畫 Instance kj_animationImplicitDuration:animations:
移動時刻顯示陰影效果 Instance kj_movingShadow
動畫組 Instance kj_animationMoreAnimations:
旋轉動畫效果 Instance kj_animationRotateClockwise:makeParameter:
移動動畫效果 Instance kj_animationMovePoint:makeParameter:
縮放動畫效果 Instance kj_animationZoomMultiple:makeParameter:
漸隱動畫效果 Instance kj_animationOpacity:makeParameter:

UIView+KJXib

功能 類型 API & Property
貝塞爾圓角 Property bezierRadius
陰影偏移量 Property shadowOffset
陰影透明度 Property shadowOpacity
陰影的寬度 Property shadowWidth
陰影的圓角 Property shadowRadius
陰影顏色 Property shadowColor
圓角半徑 Property cornerRadius
邊框寬度 Property borderWidth
邊框顏色 Property borderColor
圖片屬性 Property viewImage
判斷是否有子視圖在滾動 Property anySubViewScrolling
判斷是否有子視圖在滾動 Instance kj_anySubViewScrolling
判斷控件是否顯示在主窗口 Property showKeyWindow
判斷控件是否顯示在主窗口 Instance kj_isShowingOnKeyWindow
頂部控制器 Property topViewController
當前的控制器 Property viewController
當前的控制器 Instance kj_currentViewController
Xib創建的View Class kj_viewFromXib
Xib創建的View Class kj_viewFromXibWithFrame:

UIView+KJRectCorner 進階版圓角和邊框擴展

功能 類型 API & Property
圓角半徑 Property kj_radius
圓角方位 Property kj_rectCorner
邊框顏色 Property kj_borderColor
邊框寬度 Property kj_borderWidth
邊框方位 Property kj_borderOrientation

UIView+KJGradient 漸變處理 和 指定圖形

功能 類型 API & Property
返回漸變layer Instance kj_GradientLayerWithColors:Frame:Locations:StartPoint:EndPoint:
生成漸變背景色 Instance kj_GradientBgColorWithColors:Locations:StartPoint:EndPoint:
虛線邊框 Instance kj_DashedLineColor:lineWidth:spaceAry:
畫直線 Instance kj_DrawLineWithPoint:toPoint:lineColor:lineWidth:
畫虛線 Instance kj_DrawDashLineWithPoint:toPoint:lineColor:lineWidth:lineSpace:lineType:
畫五角星 Instance kj_DrawPentagramWithCenter:radius:color:rate:
根據寬高畫六邊形 Instance kj_DrawSexangleWithWidth:LineWidth:StrokeColor:FillColor:
根據寬高畫八邊形 Instance kj_DrawOctagonWithWidth:Height:LineWidth:StrokeColor:FillColor:Px:Py:

UIView+KJGestureBlock 手勢Block

功能 類型 API & Property
單擊手勢 Instance kj_AddTapGestureRecognizerBlock:
手勢處理 Instance kj_AddGestureRecognizer:block:

UIView+KJFrame 輕量級佈局

功能 類型 API & Property
大小 Property size
位置 Property origin
x座標 Property x
y座標 Property y
寬度 Property width
高度 Property height
中心點x Property centerX
中心點y Property centerY
左邊距離 Property left
右邊距離 Property right
頂部距離 Property top
底部距離 Property bottom
x + width Property maxX
y + height Property maxY
Masonry佈局後x Property masonry_x
Masonry佈局後y Property masonry_y
Masonry佈局後寬度 Property masonry_width
Masonry佈局後高度 Property masonry_height
將視圖中心置於其父視圖 Instance kj_centerToSuperview
距父視圖右邊距離 Instance kj_rightToSuperview:
距父視圖下邊距離 Instance kj_bottomToSuperview:
獲取子視圖的最高Y Instance kj_subviewMaxY
獲取子視圖的最高X Instance kj_subviewMaxX
尋找子視圖 Instance kj_FindSubviewRecursively:
移除所有子視圖 Instance kj_removeAllSubviews
隱藏/顯示所有子視圖 Instance kj_hideSubviews:operation:
子控件處理手勢事件 Instance kj_childHitTest:withEvent:

<a id="UITextView"></a>UITextView

UITextView+KJBackout 撤銷處理,相當於 command + z

功能 類型 API & Property
是否開啓撤銷功能 Property kOpenBackout
撤銷輸入 Instance kj_textViewBackout

UITextView+KJPlaceHolder

功能 類型 API & Property
佔位符文字 Property placeHolder
佔位符Label Property placeHolderLabel

UITextView+KJLimitCounter 限制處理

功能 類型 API & Property
限制字數 Property limitCount
限制區域右邊距 Property limitMargin
限制區域高度 Property limitHeight
統計限制字數Label Property limitLabel

UITextView+KJHyperlink 超鏈接點擊處理

功能 類型 API & Property
識別點擊TextView裏面的超鏈接網址地址 Instance kj_clickTextViewURLCustom:URLHyperlink:

<a id="UITextField"></a>UITextField

UITextField+KJExtension 輸入框擴展,快速設置賬號密碼框

功能 類型 API & Property
設置底部邊框線條顏色 Property bottomLineColor
佔位placeholder顏色 Property placeholderColor
佔位文字字體大小 Property placeholderFontSize
最大長度 Property maxLength
明文暗文切換 Property securePasswords
達到最大字符長度 Property kMaxLengthBolck
文本編輯時刻回調 Property kTextEditingChangedBolck
設置左邊視圖,類似賬號密碼標題 Instance kj_leftView:
設置右邊視圖,類似小圓叉 Instance kj_rightViewTapBlock:ImageName:Width:Padding:

<a id="UITabBar"></a>UITabBar

UITabBar+KJBadge 顯示小紅點

功能 類型 API & Property
當前的TabBar個數 Protocol kj_tabBarCount:
顯示小紅點 Instance kj_showRedBadgeOnItemIndex:
隱藏小紅點 Instance kj_hideRedBadgeOnItemIndex:

<a id="UISlider"></a>UISlider

KJColorSlider 漸變色滑塊

功能 類型 API & Property
顏色數組 Property colors
每個顏色對應的位置信息 Property locations
顏色的高度 Property colorHeight
邊框寬度 Property borderWidth
邊框顏色 Property borderColor
回調處理時間 Property timeSpan
當前進度,用於外界kvo Property progress
移動回調處理 Property kValueChangeBlock
移動結束回調處理 Property kMoveEndBlock
重新設置UI Instance kj_setUI

UISlider+KJTapValue 滑桿點擊改值

功能 類型 API & Property
是否開啓滑桿點擊修改值 Property kTapValue

<a id="UIScrollView"></a>UIScrollView

UIScrollView+KJEmptyDataSet DZNEmptyDataSet 基礎上再次封裝沒數據時狀態

功能 類型 API & Property
是否正在加載 Property loading
視圖的垂直位置 Property verticalOffset
空數據圖片名 Property loadedImageName
空數據詳情信息 Property descriptionText
刷新按鈕文字 Property kLoadedButton
加載時刻展示的視圖 Property kLoadingContentView
刷新按鈕點擊事件 Property kLoadedButtonClick
其他視圖點擊事件 Property kLoadedOtherViewClick

<a id="UIResponder"></a>UIResponder

UIResponder+KJChain 響應鏈處理

功能 類型 API & Property
響應鏈詳情 Property kChainDescription
第一響應者 Property kFirstResponder
Instance kj_responderWithClass:
Instance kj_responderSendAction:Sender:

UIResponder+KJAdapt 簡單的屏幕比例適配

功能 類型 API & Property
設計圖機型 Protocol kj_adaptModelType:
水平比例適配 Function KJAdaptScaleLevel
豎直比例適配 Function KJAdaptScaleVertical
適配CGpoint Function KJAdaptPointMake
適配CGSize Function KJAdaptSizeMake
適配CGRect Function KJAdaptRectMake
適配UIEdgeInsets Function KJAdaptEdgeInsetsMake

<a id="UINavigation"></a>UINavigation

UINavigationBar+KJExtension

功能 類型 API & Property
設置navigationBar背景顏色 Property kj_BackgroundColor
設置基礎的透明度 Property kj_Alpha
Property kj_TranslationY
重置 Instance kj_reset

UINavigationItem+KJExtension Item鏈式生成

功能 類型 API & Property
鏈式生成 Instance kj_makeNavigationItem:
ExtendParameterBlock 擴展參數 Property kAddBarButtonItemInfo
ExtendParameterBlock 擴展參數 Property kAddLeftBarButtonItem
ExtendParameterBlock 擴展參數 Property kAddRightBarButtonItem

<a id="UILabel"></a>UILabel

UILabel+KJCopy UILabel添加長按複製功能

功能 類型 API & Property
是否可以拷貝 Property copyable
移除拷貝長按手勢 Instance kj_removeCopyLongPressGestureRecognizer

UILabel+KJExtension 文本位置和尺寸獲取

功能 類型 API & Property
設置文字內容顯示位置 Property customTextAlignment
獲取寬度 Instance kj_calculateWidth
獲取高度 Instance kj_calculateHeightWithWidth:
獲取高度,指定行高 Instance kj_calculateHeightWithWidth:OneLineHeight:
獲取文字尺寸 Class kj_calculateLabelSizeWithTitle:font:constrainedToSize:lineBreakMode:

UILabel+KJCreate 快速創建文本

功能 類型 API & Property
快速創建文本 Class kj_createLabel:

UILabel+KJAttributedString 富文本

功能 類型 API & Property
Range之間文字行間距 Instance kj_AttributedStringTextLineSpace:
Range之間文字大小 Instance kj_AttributedStringTextFont:Range:
Range之間文字顏色 Instance kj_AttributedStringTextColor:Range:
Range之間文字大小和顏色 Instance kj_AttributedStringTextFont:TextColor:Range:
Range之間文字相關屬性 Instance kj_AttributedStringTextAttributes:Range:
富文本文字大小 Instance kj_AttributedStringTextFont:Loc:Len:
富文本文字顏色 Instance kj_AttributedStringTextColor:Loc:Len:
富文本文字大小和顏色 Instance kj_AttributedStringTextFont:TextColor:Loc:Len:
富文本文字相關屬性 Instance kj_AttributedStringTextAttributes:Loc:Len:

<a id="UIImageView"></a>UIImageView

UIImageView+KJBlur 模糊處理(高斯模糊、Accelerate模糊、毛玻璃、蒙版)

功能 類型 API & Property
模糊處理 Instance kj_blurImageViewWithBlurType:BlurImage:BlurRadius:

UIImageView+KJLetters 文字頭像,首字母縮略頭像

功能 類型 API & Property
顯示文字圖片 Instance kj_imageViewWithText:LettersInfo:
瀏覽頭像,點擊全屏展示 Instance kj_headerImageShowScreen
瀏覽頭像,背景顏色 Instance kj_headerImageShowScreenWithBackground:

<a id="UIImage"></a>UIImage

UIImage+KJQRCode 二維碼/條形碼生成器,特別備註文字不能是中文漢字

功能 類型 API & Property
將字符串轉成條形碼 Class kj_barCodeImageWithContent:
生成二維碼 Class kj_QRCodeImageWithContent:codeImageSize:
生成指定顏色二維碼 Class kj_QRCodeImageWithContent:codeImageSize:color:
生成條形碼 Class kj_barcodeImageWithContent:codeImageSize:
生成指定顏色條形碼 Class kj_barcodeImageWithContent:codeImageSize:color:
改變圖片尺寸,bitmap方式 Instance kj_bitmapChangeImageSize:
改變圖片內部像素顏色 Instance kj_changeImagePixelColor:

UIImage+KJURLSize 獲取網絡圖片尺寸

功能 類型 API & Property
獲取網絡圖片尺寸 Class kj_imageGetSizeWithURL:
異步等待獲取網絡圖片大小,信號量 Class kj_imageAsyncGetSizeWithURL:

UIImage+KJScale 圖片尺寸處理

功能 類型 API & Property
通過比例來縮放圖片 Instance kj_scaleImage:
以固定寬度縮放圖像 Instance kj_scaleWithFixedWidth:
以固定高度縮放圖像 Instance kj_scaleWithFixedHeight:
等比改變圖片尺寸 Instance kj_cropImageWithAnySize:
等比縮小圖片尺寸 Instance kj_zoomImageWithMaxSize:
不拉昇填充圖片 Instance kj_fitImageWithSize:

UIImage+KJPhotoshop

功能 類型 API & Property
獲取圖片平均顏色 Instance kj_getImageAverageColor
獲得灰度圖 Instance kj_getGrayImage
改變圖片透明度 Instance kj_changeImageAlpha:
改變圖片背景顏色 Instance kj_changeImageColor:
修改圖片線條顏色 Instance kj_imageLinellaeColor:
圖層混合 Instance kj_imageBlendMode:TineColor:

UIImage+KJMask 蒙版處理,圖片拼接

功能 類型 API & Property
文字水印 Instance kj_waterText:direction:textColor:font:margin:
圖片水印 Instance kj_waterImage:direction:waterSize:margin:
圖片添加水印 Instance kj_waterMark:InRect:
蒙版圖片處理 Instance kj_maskImage:
圓形圖片 Instance kj_circleImage
橢圓形圖片 Instance kj_ellipseImage
圖片透明區域點擊穿透處理 Instance kj_transparentWithPoint:

UIImage+KJJoint 圖片拼接相關處理

功能 類型 API & Property
旋轉圖片和鏡像處理 Instance kj_rotationImageWithOrientation:
豎直方向拼接隨意張圖片,固定主圖的寬度 Instance kj_moreJointVerticalImage:
水平方向拼接隨意張圖片,固定主圖的高度 Instance kj_moreJointLevelImage:
圖片多次合成處理 Instance kj_imageCompoundWithLoopNums:Orientation:
水平方向拼接隨意張圖片,固定主圖的高度 Instance kj_moreAccelerateJointLevelImage:
圖片拼接藝術 Instance kj_jointImageWithJointType:Size:Maxw:
進階版圖片拼接藝術,待完善 Instance kj_jointImageWithAdvanceJointType:Size:Maxw:Parameter:

UIImage+KJGIF 播放動態圖

功能 類型 API & Property
本地動態圖播放 Class kj_gifLocalityImageWithName:
本地動圖 Class kj_gifImageWithData:
網絡動圖 Class kj_gifImageWithURL:

UIImage+KJFloodFill 基於掃描線的泛洪算法,獲取填充同顏色區域後的圖片

功能 類型 API & Property
填充圖片 Instance kj_FloodFillImageFromStartPoint:NewColor:Tolerance:UseAntialias:

UIImage+CoreImage CoreImage框架整理

功能 類型 API & Property
Photoshop濾鏡 Instance kj_coreImagePhotoshopWithType:Value:
通用方法 Instance kj_coreImageCustomWithName:Dicts:
高光和陰影 Instance kj_coreImageHighlightShadowWithHighlightAmount:ShadowAmount:
將圖片黑色變透明 Instance kj_coreImageBlackMaskToAlpha
馬賽克 Instance kj_coreImagePixellateWithCenter:Scale:
圖片圓形變形 Instance kj_coreImageCircularWrapWithCenter:Radius:Angle:
環形透鏡畸變 Instance kj_coreImageTorusLensDistortionCenter:Radius:Width:Refraction:
空變形 Instance kj_coreImageHoleDistortionCenter:Radius:
應用透視校正 Instance kj_coreImagePerspectiveCorrectionWithTopLeft:TopRight:BottomRight:BottomLeft:
透視變換 Instance kj_coreImagePerspectiveTransformWithTopLeft:TopRight:BottomRight:BottomLeft:
軟裝專屬透視 Instance kj_softFitmentFluoroscopyWithTopLeft:TopRight:BottomRight:BottomLeft:

UIImage+KJCompress 圖片壓縮處理,提供幾種系統API的處理方式

功能 類型 API & Property
壓縮圖片到指定大小 Instance kj_compressTargetByte:
壓縮圖片到指定大小 Class kj_compressImage:TargetByte:
UIKit方式 Instance kj_UIKitChangeImageSize:
Quartz 2D Instance kj_QuartzChangeImageSize:
ImageIO Instance kj_ImageIOChangeImageSize:
CoreImage Instance kj_CoreImageChangeImageSize:
Accelerate Instance kj_AccelerateChangeImageSize:

UIImage+KJCapture 截圖和裁剪處理

功能 類型 API & Property
當前視圖截圖 Class kj_captureScreen:
指定位置屏幕截圖 Class kj_captureScreen:Rect:
自定義質量的截圖,quality質量倍數 Class kj_captureScreen:Rect:Quality:
截取當前屏幕(窗口截圖) Class kj_captureScreenWindow
截取當前屏幕(根據手機方向旋轉) Class kj_captureScreenWindowForInterfaceOrientation
截取滾動視圖的長圖 Class kj_captureScreenWithScrollView:ContentOffset:
裁剪掉圖片周圍的透明部分 Class kj_cutImageRoundAlphaZero:
不規則圖形切圖 Class kj_anomalyCaptureImageWithView:BezierPath:
多邊形切圖 Class kj_polygonCaptureImageWithImageView:PointArray:
指定區域裁剪 Class kj_cutImageWithImage:Frame:
quartz 2d 實現裁剪 Class kj_quartzCutImageWithImage:Frame:
圖片路徑裁剪,裁剪路徑 "以外" 部分 Class kj_captureOuterImage:BezierPath:Rect:
圖片路徑裁剪,裁剪路徑 "以內" 部分 Class kj_captureInnerImage:BezierPath:Rect:

UIImage+KJAccelerate Accelerate 框架的圖片處理

功能 類型 API & Property
圖片旋轉 Instance kj_rotateInRadians:
模糊處理 Instance kj_blurImageSoft
模糊處理 Instance kj_blurImageLight
模糊處理 Instance kj_blurImageExtraLight
模糊處理 Instance kj_blurImageDark
指定顏色線性模糊 Instance kj_blurImageWithTintColor:
線性模糊,保留透明區域 Instance kj_linearBlurryImageBlur:
模糊處理 Instance kj_blurImageWithRadius:Color:MaskImage:
均衡運算 Instance kj_equalizationImage
侵蝕 Instance kj_erodeImage
形態膨脹/擴張 Instance kj_dilateImage
多倍侵蝕 Instance kj_erodeImageWithIterations:
形態多倍膨脹/擴張 Instance kj_dilateImageWithIterations:
梯度 Instance kj_gradientImageWithIterations:
頂帽運算 Instance kj_tophatImageWithIterations:
黑帽運算 Instance kj_blackhatImageWithIterations:
卷積處理 Instance kj_convolutionImageWithKernel:
銳化 Instance kj_sharpenImage
銳化 Instance kj_sharpenImageWithIterations:
浮雕 Instance kj_embossImage
高斯 Instance kj_gaussianImage
邊緣檢測 Instance kj_marginImage
邊緣檢測 Instance kj_edgeDetection

<a id="UIDevice"></a>UIDevice

UIDevice+KJSystem 系統相關的操作

功能 類型 API & Property
App版本號 Class & Property appCurrentVersion
App名稱 Class & Property appName
手機UUID Class & Property deviceID
獲取App圖標 Class & Property appIcon
判斷App是否支持橫屏 Class & Property supportHorizontalScreen
獲取啓動頁圖片 Class & Property launchImage
系統啓動圖緩存路徑 Class & Property launchImageCachePath
啓動圖備份文件路徑 Class & Property launchImageBackupPath
生成啓動圖 Class kj_launchImageWithPortrait:Dark:
生成啓動圖 Class kj_launchImageWithStoryboard:Portrait:Dark:
對比版本號 Class kj_comparisonVersion:
獲取AppStore版本號和詳情信息 Class kj_getAppStoreVersionWithAppid:Details:
跳轉到指定URL Class kj_openURL:
調用AppStore Class kj_skipToAppStoreWithAppid:
調用自帶瀏覽器safari Class kj_skipToSafari
調用自帶Mail Class kj_skipToMail
是否切換爲揚聲器 Class kj_changeLoudspeaker:
保存到相冊 Class kj_savedPhotosAlbumWithImage:Complete:
系統自帶分享 Class kj_shareActivityWithItems:ViewController:Complete:
切換根視圖控制器 Class kj_changeRootViewController:Complete:

<a id="UIControl"></a>UIControl

UISegmentedControl+KJCustom

功能 類型 API & Property
解決修改背景色和文字顏色 Instance kj_ensureBackgroundAndTintColor:

<a id="UIColor"></a>UIColor

UIColor+KJExtension 顏色相關擴展

功能 類型 API & Property
漸變顏色 Class zj_gradientColorWithColors:GradientType:Size:
豎直漸變顏色 Instance kj_gradientVerticalToColor:Height:
橫向漸變顏色 Instance kj_gradientAcrossToColor:Width:
生成附帶邊框的漸變色圖片 Class kj_colorImageWithColors:locations: size:borderWidth:borderColor:
UIColor轉16進制字符串 Class kj_hexStringFromColor:
16進制字符串轉UIColor Class kj_colorWithHexString:
獲取圖片上指定點的顏色 Class kj_colorAtImage:Point:
獲取ImageView上指定點的圖片顏色 Class kj_colorAtImageView:Point:

UIColor+KJExtension2 顏色相關擴展

功能 類型 API & Property
Property red
Property green
Property blue
Property alpha
色相 Property hue
飽和度 Property saturation
亮度 Property light
獲取顏色對應的RGBA Instance kj_colorGetRGBA
獲取顏色對應的色相飽和度和透明度 Instance kj_colorGetHSL
獲取顏色的均值 Class kj_averageColors:

<a id="UIButton"></a>UIButton

UIButton+KJBlock 點擊事件ButtonBlock

功能 類型 API & Property
是否開啓時間間隔的方法交換 Protocol kj_openTimeExchangeMethod
添加點擊事件 Instance kj_addAction:
添加事件,不支持多枚舉形式 Instance kj_addAction:forControlEvents:
點擊事件間隔 Property timeInterval

UIButton+KJContentLayout 圖文混排(支持XIB顯示)

功能 類型 API & Property
圖文樣式 Property layoutType
圖文間距 Property padding
圖文邊界的間距 Property periphery
圖文樣式 Property kj_ButtonContentLayoutType
圖文間距 Property kj_Padding
圖文邊界的間距 Property kj_PaddingInset

UIButton+KJCountDown 倒計時

功能 類型 API & Property
倒計時結束的回調 Property kButtonCountDownStop
設置倒計時的間隔和倒計時文案 Instance kj_startTime:CountDownFormat:
取消倒計時 Instance kj_cancelTimer

UIButton+KJCreate 按鈕快速創建

功能 類型 API & Property
創建圖片按鈕 Class kj_createButton:

UIButton+KJEmitter 按鈕粒子效果

功能 類型 API & Property
是否開啓粒子效果 Property openEmitter
粒子,備註 name 屬性不要更改 Property emitterCell
設置粒子效果 Instance kj_buttonSetEmitterImage:OpenEmitter:

UIButton+KJEnlarge 改變UIButton的響應區域 - 擴大Button點擊域

功能 類型 API & Property
設置按鈕額外熱區 Property touchAreaInsets
擴大點擊域 Instance kj_EnlargeEdgeWithTop:right:bottom:left:

UIButton+KJIndicator 指示器(系統自帶菊花)

功能 類型 API & Property
按鈕是否正在提交中 Property submitting
指示器和文字間隔 Property indicatorSpace
指示器顏色 Property indicatorType
開始提交,指示器跟隨文字 Instance kj_beginSubmitting:
結束提交 Instance kj_endSubmitting
顯示指示器 Instance kj_showIndicator
隱藏指示器 Instance kj_hideIndicator

<a id="UICollectionView"></a>UICollectionView

UICollectionView+KJTouch 獲取touch事件處理

功能 類型 API & Property
開啓方法交換 Property kOpenExchange
Touch裏面移動回調 Property moveblock

<a id="UIBezierPath"></a>UIBezierPath

UIBezierPath+KJPoints 獲取貝塞爾曲線上面的點

功能 類型 API & Property
獲取所有點 Property points
獲取文字貝塞爾路徑 Class kj_bezierPathWithText:Font:

<a id="NSObject"></a>NSObject

KJGeometry 幾何方程式相關

功能 類型 API & Property
已知A、B兩點和C點到B點的長度,求垂直AB的C點 Class kj_perpendicularLineDotsWithA:B:Len:Positive:
已知A、B兩點和C點到B點的長度,求垂直AB的C點 Class kj_perpendicularLineDotsWithA:B:Length:
已知A、B、C、D 4個點,求AB與CD交點 Class kj_linellaeCrosspointWithA:B:C:D:
求兩點線段長度 Class kj_distanceBetweenPointsWithA:B:
已知A、B、C三個點,求AB線對應C的平行線上的點 Class kj_parallelLineDotsWithA:B:C:
橢圓求點方程 Class kj_ovalPointWithRect:Angle:

KJMathEquation 數學算法方程式

功能 類型 API & Property
把弧度轉換成角度 Class kj_degreeFromRadian:
把角度轉換成弧度 Class kj_radianFromDegree:
正切函數的弧度值,tan Class kj_radianValueFromTanSideA:sideB:
獲取具有固定寬度的新size Class kj_resetFromSize:FixedWidth:
獲取具有固定高度的新size Class kj_resetFromSize:FixedHeight:
一元一次線性方程,求k,b Class kj_mathOnceLinearEquationWithPointA:PointB:
已知y,k,b 求 x Class kj_xValueWithY:LinearEquation:
已知x,k,b 求 y Class kj_yValueWithX:LinearEquation:

NSObject+KJKVO 鍵值監聽封裝,自動釋放

功能 類型 API & Property
kvo監聽 Instance kj_observeKey:ObserveResultBlock:

NSObject+KJRuntime Runtime輕量級封裝

功能 類型 API & Property
獲取該對象的所有屬性,包含父類 Property propertyTemps
實例變量列表 Property ivarTemps
方法列表 Property methodTemps
遵循的協議列表 Property protocolTemps
歸檔封裝 Instance kj_encodeRuntime:
解檔封裝 Instance kj_initCoderRuntime:

NSObject+KJSemaphore 輕量級解耦工具(信號)

功能 類型 API & Property
發送消息處理 Instance kj_sendSemaphoreWithKey:Message:Parameter:
接收消息處理 Instance kj_receivedSemaphoreBlock:
代碼執行時間處理 Class kj_executeTime:

<a id="NSDictionary"></a>NSDictionary

NSDictionary+KJExtension

功能 類型 API & Property
是否爲空 Property isEmpty
轉換爲Josn字符串 Property jsonString

<a id="NSString"></a>NSString

NSString+KJExtension 字符串擴展屬性

功能 類型 API & Property
是否爲空 Property isEmpty
轉換爲URL Property URL
獲取圖片 Property image
取出HTML Property HTMLString
Josn字符串轉字典 Property jsonDict
生成豎直文字 Property verticalText
獲取文本寬度 Instance kj_maxWidthWithFont:Height:Alignment:LinebreakMode:LineSpace:
獲取文本高度 Instance kj_maxHeightWithFont:Width:Alignment:LinebreakMode:LineSpace:
文字轉圖片 Instance kj_textBecomeImageWithSize:BackgroundColor:TextAttributes:

NSString+KJChinese 漢字相關處理

功能 類型 API & Property
漢字轉拼音 Property pinYin
隨機漢字 Class kj_randomCreateChinese:
查找數據 Instance kj_searchArray:
字母排序 Instance kj_letterSortArray:

NSString+KJPredicate 謂詞工具

功能 類型 API & Property
過濾空格 Instance kj_filterSpace
驗證數字 Instance kj_validateNumber
是否有特殊字符 Instance kj_validateHaveSpecialCharacter
過濾特殊字符 Instance kj_removeSpecialCharacter:
驗證手機號碼 Instance kj_validateMobileNumber
驗證郵箱格式 Instance kj_validateEmail
驗證身份證 Instance kj_validateIDCardNumber
驗證銀行卡 Instance kj_validateBankCardNumber

NSString+KJSecurity 加密解密工具,鏈式處理

功能 類型 API & Property
生成key Instance kj_createKey
生成token Instance kj_createToken
RSA公鑰加密 Instance kj_rsaEncryptPublicKey
RSA公鑰解密 Instance kj_rsaDecryptPublicKey
RSA私鑰加密 Instance kj_rsaEncryptPrivateKey
RSA私鑰解密 Instance kj_rsaDecryptPrivateKey
AES加密 Instance kj_aesEncryptKey
AES解密 Instance kj_aesDecryptKey
Base64編碼 Instance kj_base64EncodedString
Base64解碼 Instance kj_base64DecodingString

<a id="NSTimer"></a>NSTimer

NSTimer+KJExtension

功能 類型 API & Property
當前線程計時器 Class kj_scheduledTimerWithTimeInterval:Repeats:Block:
當前線程 Class kj_scheduledTimerWithTimeInterval:Repeats:Block:RunLoopMode:
線程計時器 Class kj_timerWithTimeInterval:Repeats:Block:
立刻執行 Instance kj_immediatelyTimer
暫停 Instance kj_pauseTimer
重啓計時器 Instance kj_resumeTimer
延時執行 Instance kj_resumeTimerAfterTimeInterval:
釋放計時器 Class kj_invalidateTimer:

<a id="NSArray"></a>NSArray

NSArray+KJPredicate 謂詞工具

功能 類型 API & Property
對比兩個數組刪除相同元素併合並 Instance kj_mergeArrayAndDelEqualObjWithOtherArray:
過濾數組 Instance kj_filtrationDatasWithPredicateBlock:
除去數組當中包含目標數組的數據 Instance kj_delEqualDatasWithTargetTemps:
按照某一屬性的升序降序排列 Instance kj_sortDescriptorWithKey:Ascending:
按照某些屬性的升序降序排列 Instance kj_sortDescriptorWithKeys:Ascendings:
取出 key 中匹配 value 的元素 Instance kj_takeOutDatasWithKey:Value:
字符串比較運算符 Instance kj_takeOutDatasWithOperator:Key:Value:

NSArray+KJExtension 對數組裏面元素的相關處理

功能 類型 API & Property
是否爲空 Property isEmpty
篩選數據 Instance kj_detectArray:
多維數組篩選數據 Instance kj_detectManyDimensionArray:
查找數據 Instance kj_searchObject:
映射 Instance kj_mapArray:
插入數據到目的位置 Instance kj_insertObject:
數組計算交集 Instance kj_arrayIntersectionWithOtherArray:
數組計算差集 Instance kj_arrayMinusWithOtherArray:
隨機打亂數組 Instance kj_disorganizeArray
刪除數組當中的相同元素 Instance kj_delArrayEquelObj
生成一組不重複的隨機數 Instance kj_noRepeatRandomArrayWithMinNum:maxNum:count:
二分查找 Instance kj_binarySearchTarget:
冒泡排序 Instance kj_bubbleSort
插入排序 Instance kj_insertSort
選擇排序 Instance kj_selectionSort

這個真的是手都複製粘貼痛了,老闆們點個星星鼓勵一下 - -

Demo地址KJEmitterView、圖文介紹 哆啦A夢工具庫介紹

備註:本文用到的部分函數方法和Demo,均來自三方庫KJEmitterView,如有需要的朋友可自行pod 'KJEmitterView'引入即可

功能介紹就到此完畢,後面有相關再補充,寫文章不容易,還請點個小星星傳送門

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章