Latest 1.0.5
Homepage https://github.com/wenmobo/WBCategoryKit
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit, Foundation, WebKit, AVFoundation, MobileCoreServices, Photos, AssetsLibrary, QuartzCore, Accelerate, ImageIO, CoreText, CoreGraphics, CoreTelephony
Authors

WBCategoryKit
WBCategoryKit
WBCategoryKit
WBCategoryKit
WBCategoryKit
WBCategoryKit

中文说明

Some useful Objective-C ategories and Macro,that contain UIKit.framework、Foundation.framework、AVFoundation.framework、QuartzCore. framework、CoreTelephony.framework、WebKit.framework、MobileCoreServices.framework、Photos.framework、AssetsLibrary.framework、Accelerate.framework、ImageIO.framework、CoreText.framework、CoreGraphics.framework and so on,i will continue to tidy up updates.

iOS 系统常用框架分类封装,开发常用宏定义,支持cocoapod集成,支持只集成子模块。持续更新中…

Requirements

  • iOS 8+
  • Xcode 8+

Installation

Cocoapods安装

  • 安装所有分类文件
    pod 'WBCategoryKit'
  • 集成子组件
    pod 'WBCategoryKit/UIKit'

    或者

    pod 'WBCategoryKit/UIKit/WKWebView'

手动集成

将需要的分类文件拖入工程即可。

Usage

Foundation

  • NSObject
    
    //swizzle 类方法
  • (void)swizzleClassMethodWithOriginSel:(SEL)oriSel
    swizzledSel:(SEL)swiSel
    selfClass:(Class)selfClass;

//swizzle 实例方法 
+ (void)swizzleInstanceMethodWithOriginSel:(SEL)oriSel
                               swizzledSel:(SEL)swiSel
                                 selfClass:(Class)selfClass;
  • NSDate
    
    //NSDateFormatter缓存 
  • (NSDateFormatter )wb_dateFormatterWithFormat:(NSString )format;

//朋友圈时间格式

+ (NSString *)compareCurrentTimeWithTimeString:(NSString *)timeString;

Macro

//设置平方字体PingFangSC

#define kWB_PFR kWB_SYSTEM_VERSION_9_OR_LATER ? @"PingFangSC-Regular" : @"PingFang SC"
#define kWB_PFR_FONT(s) [UIFont fontWithName:kWB_PFR size:s]

//主线程安全执行

#ifndef dispatch_main_async_safe
#define dispatch_main_async_safe(block) dispatch_queue_async_safe(dispatch_get_main_queue(), block)
#endif

//同步锁

#define kWB_LOCK(lock) dispatch_semaphore_wait(lock, DISPATCH_TIME_FOREVER);
#define kWB_UNLOCK(lock) dispatch_semaphore_signal(lock);

UIKit

  • WKWebView
    
    //获取某个标签的结点个数
  • (void)wb_nodeCountOfTag:(NSString *)tag
    completedHandler:(void (^) (int tagCount))completedHandler;

//获取网页中的图片 
- (void)wb_getImages:(void (^) (NSArray *images))completedHandler;
//获取网页内容高度
- (void)wb_getScrollHeight:(void (^) (CGFloat scrollHeight))completedHandler;
//为所有图片添加点击事件
- (void)wb_addClickEventOnImg;
//根据id隐藏网页元素
- (void)wb_hiddenElementById:(NSString *)idString;
  • UIFont
    
    //runtime字体适配
  • (UIFont *)_wb_systemFontOfSize:(CGFloat)fontSize;
  • (UIFont *)_wb_boldSystemFontOfSize:(CGFloat)fontSize;
  • (UIFont )_wb_fontWithName:(NSString )fontName
    size:(CGFloat)fontSize;

    
    
    更多分类使用方法,请查看demo。

补充

本库主要是记录自己积累学习的一个过程,最初在github创建这个工程的时候,我就在自己的博客中写道将来有一天将本库制作成pod公有库,如今完成了本库的制作,虽然在制作过程中遇到了很多的问题,但还是很有成就感。如过在使用过程中,有任何建议或者问题,可以通过以下方式联系我,十分感谢。

author:wenbo
QQ:1050794513
email:[email protected]

喜欢就❤️下鼓励下吧。

更新

  • 2018-09-05 (1.0.2): 修改podspec文件,支持三级目录。

License

WBCategoryKit is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "WBCategoryKit",
    "version": "1.0.5",
    "summary": "Some useful Objective-C Categories and Macro",
    "homepage": "https://github.com/wenmobo/WBCategoryKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "wenmobo": "[email protected]"
    },
    "source": {
        "git": "https://github.com/wenmobo/WBCategoryKit.git",
        "tag": "1.0.5"
    },
    "social_media_url": "http://blogwenbo.com/",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "WBCategoryKit/WBCategoryKit.h",
    "frameworks": [
        "UIKit",
        "Foundation",
        "WebKit",
        "AVFoundation",
        "MobileCoreServices",
        "Photos",
        "AssetsLibrary",
        "QuartzCore",
        "Accelerate",
        "ImageIO",
        "CoreText",
        "CoreGraphics",
        "CoreTelephony"
    ],
    "requires_arc": true,
    "subspecs": [
        {
            "name": "Foundation",
            "source_files": "WBCategoryKit/Foundation/WBFoundation.h",
            "frameworks": [
                "Foundation",
                "UIKit"
            ],
            "subspecs": [
                {
                    "name": "NSData",
                    "source_files": "WBCategoryKit/Foundation/NSData/**/*.{h,m}",
                    "frameworks": "Foundation"
                },
                {
                    "name": "NSDictionary",
                    "source_files": "WBCategoryKit/Foundation/NSDictionary/**/*.{h,m}",
                    "frameworks": "Foundation",
                    "dependencies": {
                        "WBCategoryKit/Foundation/NSString": []
                    }
                },
                {
                    "name": "NSString",
                    "source_files": "WBCategoryKit/Foundation/NSString/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit",
                        "CoreTelephony"
                    ]
                },
                {
                    "name": "NSArray",
                    "source_files": "WBCategoryKit/Foundation/NSArray/**/*.{h,m}",
                    "frameworks": "Foundation"
                },
                {
                    "name": "NSUserDefaults",
                    "source_files": "WBCategoryKit/Foundation/NSUserDefaults/**/*.{h,m}",
                    "frameworks": "Foundation"
                },
                {
                    "name": "NSObject",
                    "source_files": "WBCategoryKit/Foundation/NSObject/**/*.{h,m}",
                    "frameworks": "Foundation"
                },
                {
                    "name": "NSDate",
                    "source_files": "WBCategoryKit/Foundation/NSDate/**/*.{h,m}",
                    "frameworks": "Foundation"
                }
            ]
        },
        {
            "name": "Macro",
            "source_files": "WBCategoryKit/Macro/*.{h}",
            "frameworks": [
                "Foundation",
                "UIKit"
            ]
        },
        {
            "name": "QuartzCore",
            "source_files": "WBCategoryKit/QuartzCore/**/*.{h,m}",
            "frameworks": [
                "Foundation",
                "UIKit",
                "QuartzCore"
            ]
        },
        {
            "name": "UIKit",
            "source_files": "WBCategoryKit/UIKit/WBUIKit.h",
            "frameworks": [
                "Foundation",
                "UIKit",
                "WebKit",
                "AVFoundation",
                "MobileCoreServices",
                "Photos",
                "AssetsLibrary",
                "QuartzCore",
                "Accelerate"
            ],
            "subspecs": [
                {
                    "name": "UIFont",
                    "source_files": "WBCategoryKit/UIKit/UIFont/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ],
                    "dependencies": {
                        "WBCategoryKit/Foundation/NSObject": [],
                        "WBCategoryKit/Macro": []
                    }
                },
                {
                    "name": "UIImage",
                    "source_files": "WBCategoryKit/UIKit/UIImage/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit",
                        "CoreGraphics",
                        "ImageIO",
                        "CoreText",
                        "AVFoundation",
                        "Accelerate"
                    ]
                },
                {
                    "name": "UIScrollView",
                    "source_files": "WBCategoryKit/UIKit/UIScrollView/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UIScreen",
                    "source_files": "WBCategoryKit/UIKit/UIScreen/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UIWindow",
                    "source_files": "WBCategoryKit/UIKit/UIWindow/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UIApplication",
                    "source_files": "WBCategoryKit/UIKit/UIApplication/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UITableViewCell",
                    "source_files": "WBCategoryKit/UIKit/UITableViewCell/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UIButton",
                    "source_files": "WBCategoryKit/UIKit/UIButton/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UIColor",
                    "source_files": "WBCategoryKit/UIKit/UIColor/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UIAlertController",
                    "source_files": "WBCategoryKit/UIKit/UIAlertController/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UIView",
                    "source_files": "WBCategoryKit/UIKit/UIView/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit",
                        "QuartzCore"
                    ]
                },
                {
                    "name": "UINavigationItem",
                    "source_files": "WBCategoryKit/UIKit/UINavigationItem/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "WKWebView",
                    "source_files": "WBCategoryKit/UIKit/WKWebView/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit",
                        "WebKit"
                    ]
                },
                {
                    "name": "UITextView",
                    "source_files": "WBCategoryKit/UIKit/UITextView/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UICollectionView",
                    "source_files": "WBCategoryKit/UIKit/UICollectionView/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UIImagePickerController",
                    "source_files": "WBCategoryKit/UIKit/UIImagePickerController/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit",
                        "AVFoundation",
                        "MobileCoreServices",
                        "Photos",
                        "AssetsLibrary"
                    ],
                    "dependencies": {
                        "WBCategoryKit/Foundation/NSDate": []
                    }
                },
                {
                    "name": "UIBarButtonItem",
                    "source_files": "WBCategoryKit/UIKit/UIBarButtonItem/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UINavigationBar",
                    "source_files": "WBCategoryKit/UIKit/UINavigationBar/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UIViewController",
                    "source_files": "WBCategoryKit/UIKit/UIViewController/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UISearchBar",
                    "source_files": "WBCategoryKit/UIKit/UISearchBar/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UISearchBar",
                    "source_files": "WBCategoryKit/UIKit/UISearchBar/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit"
                    ]
                },
                {
                    "name": "UIControl",
                    "source_files": "WBCategoryKit/UIKit/UIControl/**/*.{h,m}",
                    "frameworks": [
                        "Foundation",
                        "UIKit",
                        "AVFoundation"
                    ]
                }
            ]
        }
    ]
}

Pin It on Pinterest

Share This