├── README.md ├── textTools ├── textTools │ ├── LXCategory │ │ ├── readme.md │ │ ├── LFUIImage+CutScreen.h │ │ ├── LFUIImage+AudioIcon.h │ │ ├── LFNSString+Currency.h │ │ ├── LFUIView+LFViewIsDisplaying.h │ │ ├── LFUIView+DKAnalyses.h │ │ ├── LFUIViewController+DKAnalyses.h │ │ ├── LFWeakProxy.h │ │ ├── LFNSObject+AddForNotification.h │ │ ├── LFUIViewController+Add.h │ │ ├── LFUIButton+EnlargeEdge.h │ │ ├── LFUINavigationController+Add.h │ │ ├── LFALAsset+Image.h │ │ ├── LFNSString+URLString.h │ │ ├── LFUIImage+Resource.h │ │ ├── LFNSNumber+Add.h │ │ ├── LFUIBarButtonItem+Add.h │ │ ├── LFALAsset+Property.h │ │ ├── LFNSCharacterSet+Add.h │ │ ├── LFUIBezierPath+Add.h │ │ ├── LFUIViewController+Add.m │ │ ├── LFNSArray+Add.h │ │ ├── LFUIImage+CutScreen.m │ │ ├── LFNSDate+Ext.h │ │ ├── LFNSDate+Update.h │ │ ├── LFUITableViewCell+LFCellMethodExtend.h │ │ ├── LFNSCharacterSet+Add.m │ │ ├── LFNSString+Currency.m │ │ ├── LFUIView+LFViewIsDisplaying.m │ │ ├── LFNSKeyedUnarchiver+Add.m │ │ ├── LFUIGestureRecognizer+Add.h │ │ ├── LFNSKeyedUnarchiver+Add.h │ │ ├── LFUIScrollView+Add.h │ │ ├── LFNSMutableArray+Add.h │ │ ├── LFNSArray+Add.m │ │ ├── LFUIView+MBProgressHUD.h │ │ ├── LFUIBarButtonItem+Add.m │ │ ├── LFNSObject+AddForKVO.h │ │ ├── LFUIScrollView+Add.m │ │ ├── LFWeakProxy.m │ │ ├── LFUITableViewCell+LFCellMethodExtend.m │ │ ├── LFALAsset+Property.m │ │ ├── LFNSNumber+Add.m │ │ ├── LFNSDate+Property.h │ │ ├── LFNSDate+Format.h │ │ ├── LFNSDictionary+Add.h │ │ ├── LFUIImage+Resource.m │ │ ├── LFUINavigationController+Add.m │ │ ├── LFCategory.h │ │ ├── LFUIGestureRecognizer+Add.m │ │ ├── LFUIApplication+Add.h │ │ ├── LFNSDate+Format.m │ │ ├── LFNSObject+AddForNotification.m │ │ ├── LFUIImage+Scale.h │ │ ├── LFNSDate+Update.m │ │ ├── LFUIBezierPath+Add.m │ │ ├── LFUIBarButtonItem+Image.h │ │ ├── LFNSDate+Property.m │ │ ├── LFUIView+DKAnalyses.m │ │ ├── LFNSBundle+Add.h │ │ ├── LFUIControl+Add.h │ │ ├── LFUIButton+EnlargeEdge.m │ │ ├── LFUIView+Badge.h │ │ ├── LFUIViewController+DKAnalyses.m │ │ ├── LFNSNotificationCenter+Add.m │ │ ├── LFNSMutableArray+Add.m │ │ ├── LFUIAlertView+Blocks.h │ │ ├── LFNSDictionary+ModelValue.h │ │ ├── LFNSBundle+Add.m │ │ ├── LFUITableView+Add.m │ │ ├── LFNSObject+AddForKVO.m │ │ ├── LFNSNotificationCenter+Add.h │ │ ├── LFUIControl+Add.m │ │ ├── LFUIImage+AudioIcon.m │ │ ├── LFUIAlertController+Blocks.h │ │ ├── LFCALayer+Add.h │ │ ├── LFUIFont+Add.h │ │ ├── LFUIDevice+Add.h │ │ ├── LFNSData+Add.h │ │ ├── LFNSString+URLString.m │ │ ├── LFALAsset+Image.m │ │ ├── LFUIView+Add.h │ │ └── LFUIApplication+Add.m │ ├── ViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── ViewController.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ └── AppDelegate.m ├── 分类分享 │ ├── NSDictionary+PropertyCode │ │ ├── NSDictionary+PropertyCode.h │ │ └── NSDictionary+PropertyCode.m │ ├── UITextField+LXExtension │ │ ├── UITextField+LXExtension.h │ │ └── UITextField+LXExtension.m │ ├── NSObject+JSON │ │ ├── NSObject+JSON.h │ │ └── NSObject+JSON.m │ ├── UIBarButtonItem+LXExtension │ │ ├── UIBarButtonItem+LXExtension.h │ │ └── UIBarButtonItem+LXExtension.m │ ├── NSDate+LXExtension │ │ ├── NSDate+LXExtension.h │ │ └── NSDate+LXExtension.m │ ├── UIView+LXExtension │ │ ├── UIView+LXExtension.h │ │ └── UIView+LXExtension.m │ ├── UIImage+LXExtension │ │ └── UIImage+LXExtension.h │ ├── NSString+LXExtension │ │ ├── NSString+LXExtension.h │ │ └── NSString+LXExtension.m │ └── 分类说明.rtf ├── textTools.xcodeproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── 工具类分享 │ ├── 1 │ └── Single.h │ ├── 2 │ └── HelperUtil.h │ ├── 3 │ ├── LXFileManager.h │ └── LXFileManager.m │ ├── 4 │ ├── LocalPushCenter.h │ └── LocalPushCenter.m │ └── 工具类说明.rtf └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # tools 2 | 项目中常用到的一些分类及工具类 3 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/readme.md: -------------------------------------------------------------------------------- 1 | LFNSData+Hash 2 | LFNSData+zlib -------------------------------------------------------------------------------- /textTools/分类分享/NSDictionary+PropertyCode/NSDictionary+PropertyCode.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | @interface NSDictionary (PropertyCode) 5 | 6 | // 生成所需要的属性代码 7 | - (void)propertyCode; 8 | 9 | @end 10 | -------------------------------------------------------------------------------- /textTools/分类分享/UITextField+LXExtension/UITextField+LXExtension.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | @interface UITextField (LXExtension) 5 | /** 占位文字颜色 */ 6 | @property (nonatomic, strong) UIColor *lx_placeholderColor; 7 | @end 8 | -------------------------------------------------------------------------------- /textTools/textTools.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /textTools/分类分享/NSObject+JSON/NSObject+JSON.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | @interface NSObject (JSON) 5 | 6 | /** 7 | * 字典或对象转成JSON字符串数据 8 | */ 9 | @property (nonatomic, copy, readonly) NSString *JSONString; 10 | 11 | @end 12 | -------------------------------------------------------------------------------- /textTools/分类分享/UIBarButtonItem+LXExtension/UIBarButtonItem+LXExtension.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | @interface UIBarButtonItem (LXExtension) 5 | + (instancetype)lx_itemWithImage:(NSString *)image highImage:(NSString *)highImage target:(id)target action:(SEL)action; 6 | @end 7 | -------------------------------------------------------------------------------- /textTools/textTools/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // textTools 4 | // 5 | // Created by Lee on 16/6/25. 6 | // Copyright © 2016年 Lee. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIImage+CutScreen.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+CutScreen.h 3 | // LaiFeng 4 | // 5 | // Created by jiangsongwen on 16/4/18. 6 | // Copyright © 2016年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (LFCutScreenAdditions) 12 | + (UIImage *)lf_cutScreen; 13 | @end 14 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIImage+AudioIcon.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+AudioIcon.h 3 | // LaiFeng 4 | // 5 | // Created by jiangsongwen on 16/4/5. 6 | // Copyright © 2016年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (LFAudioIconAdditions) 12 | -(UIImage*)lf_bringAutoIconImage; 13 | @end 14 | -------------------------------------------------------------------------------- /textTools/textTools/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // textTools 4 | // 5 | // Created by Lee on 16/6/25. 6 | // Copyright © 2016年 Lee. All rights reserved. 7 | 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSString+Currency.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Currency.h 3 | // LaiFeng 4 | // 5 | // Created by Ton on 16/3/14. 6 | // Copyright © 2016年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSString (LFCurrencyAdditions) 12 | - (NSString *)lf_localizedStringFromNumber; 13 | @end 14 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIView+LFViewIsDisplaying.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+LFViewIsDisplaying.h 3 | // LaiFeng 4 | // 5 | // Created by Ton on 15/12/3. 6 | // Copyright © 2015年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIView (LFViewIsDisplayingAdditons) 12 | - (BOOL)lf_isDisplayedInScreen; 13 | @end 14 | -------------------------------------------------------------------------------- /textTools/textTools/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // textTools 4 | // 5 | // Created by Lee on 16/6/25. 6 | // Copyright © 2016年 Lee. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIView+DKAnalyses.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+DKAnalyses.h 3 | // GCDDemo 4 | // 5 | // Created by wangxiaoxiang on 16/3/31. 6 | // Copyright © 2016年 wangxiaoxiang. All rights reserved. 7 | // 8 | 9 | 10 | 11 | #if DEBUG 12 | #import 13 | 14 | @interface UIView (LFDKAnalysesAdditions) 15 | 16 | +(NSDictionary *)lf_allocAnalysesViewsDictionary; 17 | 18 | @end 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIViewController+DKAnalyses.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+DKAnalyses.h 3 | // GCDDemo 4 | // 5 | // Created by wangxiaoxiang on 16/3/31. 6 | // Copyright © 2016年 wangxiaoxiang. All rights reserved. 7 | // 8 | 9 | 10 | 11 | #if DEBUG 12 | #import 13 | 14 | @interface UIViewController (LFDKAnalysesAdditions) 15 | 16 | +(NSDictionary *)lf_allocAnalysesDictionary; 17 | 18 | @end 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFWeakProxy.h: -------------------------------------------------------------------------------- 1 | // 2 | // LFWeakProxy.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 14/10/18. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /// 用来打破 strong reference circle... 比如 CADisplayLink / NSTimer 12 | @interface LFWeakProxy : NSProxy 13 | 14 | @property (nonatomic, weak, readonly) id target; 15 | 16 | - (instancetype)initWithTarget:(id)target; 17 | 18 | + (instancetype)proxyWithTarget:(id)target; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSObject+AddForNotification.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+LFAddForNotification.h 3 | // LaiFeng 4 | // 5 | // Created by guoyaoyuan on 16/2/23. 6 | // Copyright © 2016年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSObject (LFAddForNotification) 12 | 13 | - (void)lf_addNotifName:(NSString *)notifName block:(void(^)(NSNotification *notif))block; 14 | - (void)lf_removeNotifName:(NSString *)notifName; 15 | - (void)lf_removeAllNotif; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIViewController+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+LFAdd.h 3 | // LaiFeng 4 | // 5 | // Created by limingchen on 15/6/30. 6 | // Copyright (c) 2015年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIViewController (LFAdditions) 12 | 13 | @property(nonatomic, assign) BOOL hidesNavigationBarWhenPushed; // If YES, then when this view controller is pushed into a controller hierarchy with a navigation bar, the navigation bar will slide out. Default is NO. 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIButton+EnlargeEdge.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+EnlargeEdge.h 3 | // iTalk 4 | // 5 | // Created by Si Wen on 15/12/29. 6 | // Copyright © 2015年 Si Wen. All rights reserved. 7 | // 8 | 9 | #ifndef UIButton_EnlargeEdge_h 10 | #define UIButton_EnlargeEdge_h 11 | 12 | #import 13 | 14 | @interface UIButton (LFEnlargeEdgeAdditions) 15 | - (void)lf_setEnlargeEdge:(CGFloat) size; 16 | - (void)lf_setEnlargeEdgeWithTop:(CGFloat) top right:(CGFloat) right bottom:(CGFloat) bottom left:(CGFloat) left; 17 | @end 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUINavigationController+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+LFAdd.h 3 | // LaiFeng 4 | // 5 | // Created by limingchen on 15/3/2. 6 | // Copyright (c) 2015年 youku&tudou. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UINavigationController (LFAdditions) 12 | 13 | - (void)lf_pushViewController: (UIViewController*)controller 14 | animatedWithTransition: (UIViewAnimationTransition)transition; 15 | - (UIViewController*)lf_popViewControllerAnimatedWithTransition:(UIViewAnimationTransition)transition; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFALAsset+Image.h: -------------------------------------------------------------------------------- 1 | // 2 | // LFALAsset+Image.h 3 | // LFCategory 4 | // 5 | // Created by WangZhiWei on 16/5/19. 6 | // Copyright © 2016年 youku. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | /** 13 | * @brief 获取图片资源相应的图片 14 | */ 15 | @interface ALAsset (LFALAssetImageAdditions) 16 | 17 | /** 18 | * @brief 获取原始图片 19 | * @returns 原始图片 20 | */ 21 | - (UIImage *)lf_fullSizeImage; 22 | 23 | /** 24 | * @brief 获取全屏尺寸的照片 25 | * @returns 全屏尺寸的照片 26 | */ 27 | - (UIImage *)lf_fullScreenImage; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSString+URLString.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Ex.h 3 | // LaiFeng 4 | // 5 | // Created by xinliu on 14-5-16. 6 | // Copyright (c) 2014年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSString(LFURLStringAdditions) 12 | 13 | - (NSString*) lf_urlEncode2:(NSStringEncoding)stringEncoding; 14 | 15 | + (BOOL)lf_stringIsNull:(NSString *)string; 16 | 17 | - (NSString*) lf_urlDecode:(NSStringEncoding)stringEncoding; 18 | - (NSDictionary*)lf_queryContentsDicUsingEncoding:(NSStringEncoding)encoding; 19 | 20 | - (NSURL*)lf_toURL; 21 | @end 22 | -------------------------------------------------------------------------------- /textTools/分类分享/NSDate+LXExtension/NSDate+LXExtension.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | @interface LXDateItem : NSObject 5 | @property (nonatomic, assign) NSInteger day; 6 | @property (nonatomic, assign) NSInteger hour; 7 | @property (nonatomic, assign) NSInteger minute; 8 | @property (nonatomic, assign) NSInteger second; 9 | @end 10 | 11 | @interface NSDate (LXExtension) 12 | - (LXDateItem *)lx_timeIntervalSinceDate:(NSDate *)anotherDate; 13 | 14 | - (BOOL)lx_isToday; 15 | - (BOOL)lx_isYesterday; 16 | - (BOOL)lx_isTomorrow; 17 | - (BOOL)lx_isThisYear; 18 | //获取今天周几 19 | - (NSInteger)getNowWeekday; 20 | @end 21 | -------------------------------------------------------------------------------- /textTools/textTools/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // textTools 4 | // 5 | // Created by Lee on 16/6/25. 6 | // Copyright © 2016年 Lee. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view, typically from a nib. 20 | } 21 | 22 | - (void)didReceiveMemoryWarning { 23 | [super didReceiveMemoryWarning]; 24 | // Dispose of any resources that can be recreated. 25 | } 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIImage+Resource.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+Resource.h 3 | // LaiFeng 4 | // 5 | // Created by xinliu on 14-4-24. 6 | // Copyright (c) 2014年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface UIImage(LFResourceAdditions) 13 | 14 | 15 | /*! 16 | * @brief 获取skin_common.bundle/Images/Emotions中的表情 17 | * 18 | * @param name 表情文件名称 19 | * 20 | * @return 图片对象/如果没有返回空 21 | */ 22 | + (UIImage*)lf_EmotionWithName:(NSString*)name; 23 | 24 | + (UIImage *)lf_imageForKey:(id)key inBundle:(NSBundle *)bundle; 25 | @end 26 | -------------------------------------------------------------------------------- /textTools/工具类分享/3/LXFileManager.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | /// 文件管理类 5 | @interface LXFileManager : NSObject 6 | 7 | /// 把对象归档存到沙盒里 8 | +(void)saveObject:(id)object byFileName:(NSString*)fileName; 9 | /// 通过文件名从沙盒中找到归档的对象 10 | +(id)getObjectByFileName:(NSString*)fileName; 11 | 12 | /// 根据文件名删除沙盒中的 plist 文件 13 | +(void)removeFileByFileName:(NSString*)fileName; 14 | 15 | /// 存储用户偏好设置 到 NSUserDefults 16 | +(void)saveUserData:(id)data forKey:(NSString*)key; 17 | 18 | /// 读取用户偏好设置 19 | +(id)readUserDataForKey:(NSString*)key; 20 | 21 | /// 删除用户偏好设置 22 | +(void)removeUserDataForkey:(NSString*)key; 23 | 24 | 25 | 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSNumber+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumber+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-8-24. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provide a method to parse `NSString` for `NSNumber`. 13 | */ 14 | @interface NSNumber (LFAdd) 15 | 16 | /** 17 | 把字符串解析为NSNumber。(如解析失败则返回nil) 18 | 19 | 支持各种格式,例如 @"12", @"12.345", @" -0xFF", @" .23e99 " 20 | 不区分大小写,可以有空格 21 | */ 22 | + (NSNumber *)lf_numberWithString:(NSString *)string; 23 | 24 | /** 25 | 如果超出9999,则折叠成 XX.X 万 26 | */ 27 | - (NSString *)lf_wrappedDescription; 28 | 29 | - (NSString *)lf_toDecimalStyleString; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /textTools/分类分享/UIView+LXExtension/UIView+LXExtension.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | @interface UIView (LXExtension) 5 | /** 6 | * 快速设置控件的位置 7 | */ 8 | @property (nonatomic, assign) CGSize lx_size; 9 | @property (nonatomic, assign) CGFloat lx_width; 10 | @property (nonatomic, assign) CGFloat lx_height; 11 | @property (nonatomic, assign) CGFloat lx_x; 12 | @property (nonatomic, assign) CGFloat lx_y; 13 | @property (nonatomic, assign) CGFloat lx_centerX; 14 | @property (nonatomic, assign) CGFloat lx_centerY; 15 | 16 | /** 17 | * 快速根据xib创建View 18 | */ 19 | + (instancetype)lx_viewFromXib; 20 | 21 | /** 22 | * 判断self和view是否重叠 23 | */ 24 | - (BOOL)lx_intersectsWithView:(UIView *)view; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /textTools/分类分享/UIBarButtonItem+LXExtension/UIBarButtonItem+LXExtension.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | #import "UIBarButtonItem+LXExtension.h" 4 | 5 | @implementation UIBarButtonItem (XMGExtension) 6 | + (instancetype)lx_itemWithImage:(NSString *)image highImage:(NSString *)highImage target:(id)target action:(SEL)action 7 | { 8 | UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 9 | [button setImage:[UIImage imageNamed:image] forState:UIControlStateNormal]; 10 | [button setImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted]; 11 | [button sizeToFit]; 12 | [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside]; 13 | return [[self alloc] initWithCustomView:button]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIBarButtonItem+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-10-15. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provides extensions for `UIBarButtonItem`. 13 | */ 14 | @interface UIBarButtonItem (LFAdditions) 15 | 16 | /** 17 | The block that invoked when the item is selected. The objects captured by block 18 | will retained by the ButtonItem. 19 | 20 | @discussion This param is conflict with `target` and `action` property. 21 | Set this will set `target` and `action` property to some internal objects. 22 | */ 23 | @property (nonatomic, copy) void (^actionBlock)(id); 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /textTools/分类分享/NSObject+JSON/NSObject+JSON.m: -------------------------------------------------------------------------------- 1 | 2 | #import "NSObject+JSON.h" 3 | 4 | @implementation NSObject (JSON) 5 | 6 | - (NSString *)JSONString { 7 | 8 | NSData *JSONData = nil; 9 | if ([self isKindOfClass:[NSDictionary class]]) { // 如果self是NSDictionary 10 | 11 | JSONData = [NSJSONSerialization dataWithJSONObject:self options:NSJSONWritingPrettyPrinted error:nil]; 12 | } else if ([self isKindOfClass:[NSObject class]]) { // 如果self是继承NSObject的非字典对象 13 | 14 | JSONData = [NSJSONSerialization dataWithJSONObject:self.keyValues options:NSJSONWritingPrettyPrinted error:nil]; 15 | } 16 | 17 | return [[NSString alloc] initWithData:JSONData encoding:NSUTF8StringEncoding]; 18 | } 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFALAsset+Property.h: -------------------------------------------------------------------------------- 1 | // 2 | // ALAsset+Compare.h 3 | // LaiFeng 4 | // 5 | // Created by liuxin on 15/1/12. 6 | // Copyright (c) 2015年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | /** 13 | * @brief 图片资源比较类别 14 | */ 15 | @interface ALAsset (LFALAssetPopertyAdditions) 16 | 17 | /** 18 | * @brief 比较两个图片资源指向的对象是否相等 19 | * @param other 其他的图片资源 20 | * @returns YES 相等,否则 NO 21 | */ 22 | - (BOOL)lf_isEqual:(id)other; 23 | 24 | /** 25 | * @brief 图片资源唯一的标示 26 | * @returns 唯一的图片资源id 27 | */ 28 | - (NSString *)lf_uniqueId; 29 | 30 | /** 31 | * @brief 图片资源的拍摄时间 32 | * @returns 拍摄时间 33 | */ 34 | - (NSTimeInterval)lf_timeIntervalSince1970; 35 | 36 | @end -------------------------------------------------------------------------------- /textTools/textTools/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSCharacterSet+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSCharacterSet+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-10-28. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provides extensions for `NSCharacterSet`. 13 | */ 14 | @interface NSCharacterSet (LFNSCharacterSetAdditions) 15 | 16 | /** 17 | Returns a character set containing all Apple Emoji. 18 | */ 19 | + (NSCharacterSet *)lf_emojiCharacterSet; 20 | 21 | @end 22 | 23 | 24 | 25 | /** 26 | Provides extensions for `NSMutableCharacterSet`. 27 | */ 28 | @interface NSMutableCharacterSet (LFAdd) 29 | 30 | /** 31 | Returns a character set containing all Apple Emoji. 32 | */ 33 | + (NSMutableCharacterSet *)lf_emojiCharacterSet; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIBezierPath+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBezierPath+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 14/10/30. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provides extensions for `UIBezierPath`. 13 | */ 14 | @interface UIBezierPath (LFAdditions) 15 | 16 | /** 17 | 用文本创建贝塞尔曲线。 曲线是描绘了文字的边缘。(可以做一些有趣的效果) 18 | 19 | @discussion 这里只支持纯文本。 如果要emoji,用下面这个方法: 20 | [UIImage imageWithEmoji:size:] in `UIImage(LFAdd)`. 21 | 22 | @param text The text to generate glyph path. 23 | @param font The font to generate glyph path. 24 | @return A new path object with the text and font, or nil when an error occurs. 25 | */ 26 | + (UIBezierPath *)lf_bezierPathWithText:(NSString *)text font:(UIFont *)font; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIViewController+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+LFAdd.m 3 | // LaiFeng 4 | // 5 | // Created by limingchen on 15/6/30. 6 | // Copyright (c) 2015年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFUIViewController+Add.h" 10 | #import 11 | 12 | @implementation UIViewController (LFAdditions) 13 | 14 | static const void *_hidesNavigationBarWhenPushed = &_hidesNavigationBarWhenPushed; 15 | 16 | - (void)setHidesNavigationBarWhenPushed:(BOOL)hidesNavigationBarWhenPushed { 17 | objc_setAssociatedObject(self, _hidesNavigationBarWhenPushed, @(hidesNavigationBarWhenPushed), OBJC_ASSOCIATION_ASSIGN); 18 | } 19 | 20 | - (BOOL)hidesNavigationBarWhenPushed { 21 | return [objc_getAssociatedObject(self, _hidesNavigationBarWhenPushed) boolValue]; 22 | } 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSArray+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-4. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provide some some common method for `NSArray`. 13 | */ 14 | @interface NSArray (LFNSArrayAdditions) 15 | 16 | /// 随机返回一个对象 (如果Array空,则返回nil) 17 | - (id)lf_randomObject; 18 | 19 | /// 和 `objectAtIndex:` 类似,但超出范围不会抛异常 20 | - (id)lf_objectOrNilAtIndex:(NSUInteger)index; 21 | 22 | /// 编码为 json 字符串。 如果出错则返回nil。 内容支持NSString/NSNumber/NSDictionary/NSArray 23 | - (NSString *)lf_jsonStringEncoded; 24 | 25 | /// 编码为 json 字符串(带格式)。 如果出错则返回nil。 内容支持NSString/NSNumber/NSDictionary/NSArray 26 | - (NSString *)lf_jsonPrettyStringEncoded; 27 | 28 | @end 29 | 30 | 31 | 32 | @interface NSMutableArray (LFAdd) 33 | 34 | 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /textTools/分类分享/UIImage+LXExtension/UIImage+LXExtension.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | @interface UIImage (LXExtension) 5 | - (instancetype)lx_circleImage; 6 | // 生成一个圆形图片 7 | + (instancetype)lx_circleImageNamed:(NSString *)name; 8 | 9 | // 给定一个不要渲染的图片名称,生成一个最原始的图片 10 | + (UIImage *)imageWithOriginalImageName:(NSString *)imageName; 11 | 12 | // 模糊效果(渲染很耗时间,建议在子线程中渲染) 13 | - (UIImage *)blurImage; 14 | - (UIImage *)blurImageWithMask:(UIImage *)maskImage; 15 | - (UIImage *)blurImageWithRadius:(CGFloat)radius; 16 | - (UIImage *)blurImageAtFrame:(CGRect)frame; 17 | 18 | // 灰度效果 19 | - (UIImage *)grayScale; 20 | 21 | // 固定宽度与固定高度 22 | - (UIImage *)scaleWithFixedWidth:(CGFloat)width; 23 | - (UIImage *)scaleWithFixedHeight:(CGFloat)height; 24 | 25 | // 平均的颜色 26 | - (UIColor *)averageColor; 27 | 28 | // 裁剪图片的一部分 29 | - (UIImage *)croppedImageAtFrame:(CGRect)frame; 30 | 31 | // 将自身填充到指定的size 32 | - (UIImage *)fillClipSize:(CGSize)size; 33 | @end 34 | -------------------------------------------------------------------------------- /textTools/工具类分享/4/LocalPushCenter.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | @interface LocalPushCenter : NSObject 5 | 6 | + (NSDate *)fireDateWithWeek:(NSInteger)week 7 | hour:(NSInteger)hour 8 | minute:(NSInteger)minute 9 | second:(NSInteger)second; 10 | 11 | //本地发送推送(先取消上一个 再push现在的) 12 | + (void)localPushForDate:(NSDate *)fireDate 13 | forKey:(NSString *)key 14 | alertBody:(NSString *)alertBody 15 | alertAction:(NSString *)alertAction 16 | soundName:(NSString *)soundName 17 | launchImage:(NSString *)launchImage 18 | userInfo:(NSDictionary *)userInfo 19 | badgeCount:(NSUInteger)badgeCount 20 | repeatInterval:(NSCalendarUnit)repeatInterval; 21 | 22 | #pragma mark - 退出 23 | + (void)cancelAllLocalPhsh; 24 | 25 | + (void)cancleLocalPushWithKey:(NSString *)key; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIImage+CutScreen.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+CutScreen.m 3 | // LaiFeng 4 | // 5 | // Created by jiangsongwen on 16/4/18. 6 | // Copyright © 2016年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFUIImage+CutScreen.h" 10 | 11 | @implementation UIImage (LFCutScreenAdditions) 12 | 13 | + (UIImage *)lf_cutScreen{ 14 | return [self cutFromView:[UIApplication sharedApplication].keyWindow]; 15 | } 16 | 17 | + (UIImage *)cutFromView:(UIView *)view{ 18 | 19 | UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, 0.0f); 20 | CGContextRef context = UIGraphicsGetCurrentContext(); 21 | [view.layer renderInContext:context]; 22 | 23 | [[UIColor clearColor] setFill]; 24 | 25 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 26 | 27 | UIGraphicsEndImageContext(); 28 | // UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); 29 | return image; 30 | 31 | } 32 | @end 33 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSDate+Ext.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+NSDateExt.h 3 | // LaiFeng 4 | // 5 | // Created by xinliu on 14-6-25. 6 | // Copyright (c) 2014年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | 13 | @interface NSDate(NSDateExt) 14 | - (NSString *)lf_stringForTimeLaifeng; 15 | - (NSString *)lf_stringForDateline; 16 | - (NSString *)lf_stringForTimeToday; 17 | - (NSString *)lf_stringForTimeTomorrow; 18 | - (NSString *)lf_stringForTimeCommon; 19 | - (NSString *)lf_stringForHourLaifeng; 20 | - (NSString *)lf_stringForDayLaifeng; 21 | - (NSAttributedString *)lf_attributedStringForTimeToday; 22 | - (NSAttributedString *)lf_attributedStringForTimeTomorrow; 23 | - (NSAttributedString *)lf_attributedStringForCommon; 24 | 25 | - (NSString *)lf_stringForFeed; 26 | - (BOOL)lf_isToday; 27 | - (BOOL)lf_isYesterday; 28 | - (BOOL)lf_isTodayBirthday; 29 | - (BOOL)lf_isLast30Mins; 30 | @end 31 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSDate+Update.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+Update.h 3 | // LFCategory 4 | // 5 | // Created by WangZhiWei on 16/5/19. 6 | // Copyright © 2016年 youku. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSDate (LFUpdateAdditions) 12 | 13 | #pragma mark - 日期修改 14 | ///============================================================================= 15 | /// @name 日期修改 16 | ///============================================================================= 17 | 18 | 19 | - (NSDate *)lf_dateByAddingYears:(NSInteger)years; /// 从这个日期加上N年 20 | - (NSDate *)lf_dateByAddingMonths:(NSInteger)months; /// 从这个日期加上N月 21 | - (NSDate *)lf_dateByAddingWeeks:(NSInteger)weeks; /// 从这个日期加上N日 22 | - (NSDate *)lf_dateByAddingDays:(NSInteger)days; /// 从这个日期加上N天 23 | - (NSDate *)lf_dateByAddingHours:(NSInteger)hours; /// 从这个日期加上N小时 24 | - (NSDate *)lf_dateByAddingMinutes:(NSInteger)minutes; /// 从这个日期加上N分钟 25 | - (NSDate *)lf_dateByAddingSeconds:(NSInteger)seconds; /// 从这个日期加上N秒 26 | 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUITableViewCell+LFCellMethodExtend.h: -------------------------------------------------------------------------------- 1 | // 2 | // UITableViewCell+LFCellMethodExtend.h 3 | // LaiFeng 4 | // 5 | // Created by Ton on 15/9/11. 6 | // Copyright (c) 2015年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef NS_ENUM(NSUInteger, UIViewSeparatorDirection) { 12 | 13 | UIViewSeparatorDirectionTop, 14 | UIViewSeparatorDirectionBottom 15 | }; 16 | @interface UITableViewCell (LFCellMethodExtendAdditions) 17 | 18 | /** 19 | * 用xib创建Cell 20 | * 21 | * @return self; 22 | */ 23 | +(id)lf_loadFromXib; 24 | 25 | /** 26 | * 用代码创建Cell时候设置的cellIdentifier 27 | * 28 | * @return cellIdentifier; 29 | */ 30 | +(NSString*)lf_cellIdentifier; 31 | /** 32 | * 用代码创建Cell 33 | * 34 | * @return self; 35 | */ 36 | 37 | +(id)lf_loadFromCellStyle:(UITableViewCellStyle)cellStyle; 38 | 39 | /** 40 | * 填充cell的对象 41 | * 子类去实现 42 | */ 43 | 44 | - (void)lf_createSeparatorOfView:(UIView *)view Direction:(UIViewSeparatorDirection)direction edgeNum:(float)edgeNum; 45 | @end 46 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSCharacterSet+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSCharacterSet+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-10-28. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFNSCharacterSet+Add.h" 10 | #import "LFNSString+Add.h" 11 | #import "LFCategoryMacro.h" 12 | 13 | 14 | @implementation NSCharacterSet (LFNSCharacterSetAdditions) 15 | 16 | + (NSCharacterSet *)lf_emojiCharacterSet { 17 | static NSCharacterSet *set = nil; 18 | static dispatch_once_t onceToken; 19 | dispatch_once(&onceToken, ^{ 20 | set = [NSCharacterSet characterSetWithCharactersInString:[NSString lf_allEmoji]]; 21 | }); 22 | return set; 23 | } 24 | 25 | @end 26 | 27 | 28 | @implementation NSMutableCharacterSet (LFAdd) 29 | 30 | + (NSMutableCharacterSet *)lf_emojiCharacterSet { 31 | static NSMutableCharacterSet *set = nil; 32 | static dispatch_once_t onceToken; 33 | dispatch_once(&onceToken, ^{ 34 | set = [NSCharacterSet lf_emojiCharacterSet].mutableCopy; 35 | }); 36 | return set; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /textTools/分类分享/UITextField+LXExtension/UITextField+LXExtension.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | #import "UITextField+LXExtension.h" 4 | 5 | @implementation UITextField (LXExtension) 6 | /** 通过这个属性名,就可以修改textField内部的占位文字颜色 */ 7 | static NSString * const LXPlaceholderColorKeyPath = @"placeholderLabel.textColor"; 8 | 9 | /** 10 | * 设置占位文字颜色 11 | */ 12 | - (void)setLx_placeholderColor:(UIColor *)lx_placeholderColor 13 | { 14 | // 这3行代码的作用:1> 保证创建出placeholderLabel,2> 保留曾经设置过的占位文字 15 | NSString *placeholder = self.placeholder; 16 | self.placeholder = @" "; 17 | self.placeholder = placeholder; 18 | 19 | // 处理xmg_placeholderColor为nil的情况:如果是nil,恢复成默认的占位文字颜色 20 | if (lx_placeholderColor == nil) { 21 | lx_placeholderColor = [UIColor colorWithRed:0 green:0 blue:0.0980392 alpha:0.22]; 22 | } 23 | 24 | // 设置占位文字颜色 25 | [self setValue:lx_placeholderColor forKeyPath:LXPlaceholderColorKeyPath]; 26 | } 27 | 28 | /** 29 | * 获得占位文字颜色 30 | */ 31 | - (UIColor *)lx_placeholderColor 32 | { 33 | return [self valueForKeyPath:LXPlaceholderColorKeyPath]; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSString+Currency.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Currency.m 3 | // LaiFeng 4 | // 5 | // Created by Ton on 16/3/14. 6 | // Copyright © 2016年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFNSString+Currency.h" 10 | 11 | @implementation NSString (LFCurrencyAdditions) 12 | 13 | - (NSString *)lf_localizedStringFromNumber { 14 | if(![self isKindOfClass:[NSString class]]){ 15 | return self; 16 | } 17 | float oldf = [self floatValue]; 18 | long long oldll = [self longLongValue]; 19 | float tmptf = oldf - oldll; 20 | NSString *currencyStr = nil; 21 | if(tmptf > 0){ 22 | currencyStr = [NSNumberFormatter localizedStringFromNumber:[NSNumber numberWithFloat:oldll] 23 | numberStyle:NSNumberFormatterDecimalStyle]; 24 | }else{ 25 | currencyStr = [NSNumberFormatter localizedStringFromNumber:[NSNumber numberWithLongLong:oldll] 26 | numberStyle:NSNumberFormatterDecimalStyle]; 27 | } 28 | return currencyStr; 29 | }@end 30 | -------------------------------------------------------------------------------- /textTools/分类分享/NSString+LXExtension/NSString+LXExtension.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | 4 | @interface NSString (LXExtension) 5 | /** 6 | * md5加密 7 | */ 8 | + (NSString*)md5HexDigest:(NSString*)input; 9 | /** 10 | * 根据文件名计算出文件大小 11 | */ 12 | - (unsigned long long)lx_fileSize; 13 | /** 14 | * 生成缓存目录全路径 15 | */ 16 | - (instancetype)cacheDir; 17 | /** 18 | * 生成文档目录全路径 19 | */ 20 | - (instancetype)docDir; 21 | /** 22 | * 生成临时目录全路径 23 | */ 24 | - (instancetype)tmpDir; 25 | 26 | /** 27 | * @brief 根据字数的不同,返回UILabel中的text文字需要占用多少Size 28 | * @param size 约束的尺寸 29 | * @param font 文本字体 30 | * @return 文本的实际尺寸 31 | */ 32 | - (CGSize)textSizeWithContentSize:(CGSize)size font:(UIFont *)font; 33 | 34 | /** 35 | * @brief 根据文本字数/文本宽度约束/文本字体 求得text的Size 36 | * @param width 宽度约束 37 | * @param font 文本字体 38 | * @return 文本的实际高度 39 | */ 40 | - (CGFloat)textHeightWithContentWidth:(CGFloat)width font:(UIFont *)font; 41 | 42 | /** 43 | * @brief 根据文本字数/文本宽度约束/文本字体 求得text的Size 44 | * @param height 宽度约束 45 | * @param font 文本字体 46 | * @return 文本的实际长度 47 | */ 48 | - (CGFloat)textWidthWithContentHeight:(CGFloat)height font:(UIFont *)font; 49 | @end 50 | -------------------------------------------------------------------------------- /textTools/工具类分享/工具类说明.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg936\cocoartf1404\cocoasubrtf460 2 | {\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset134 PingFangSC-Regular;} 3 | {\colortbl;\red255\green255\blue255;} 4 | \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh5100\viewkind0 5 | \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0 6 | 7 | \f0\fs24 \cf0 1.Single 8 | \f1 \'a3\'ba\'bf\'ec\'cb\'d9\'b4\'b4\'bd\'a8\'d2\'bb\'b8\'f6\'b5\'a5\'c0\'fd 9 | \f0 \ 10 | 2.HelperUtil 11 | \f1 \'a3\'ba\'b3\'a3\'d3\'c3\'b5\'c4\'d5\'fd\'d4\'f2\'b1\'ed\'b4\'ef\'ca\'bd(\'ca\'d6\'bb\'fa\'ba\'c5\'a3\'ac\'d3\'ca\'cf\'e4\'b5\'c8) 12 | \f0 \ 13 | 3.LXFileManager: 14 | \f1 \'bd\'ab\'b6\'d4\'cf\'f3\'c8\'a1\'b9\'e9\'b5\'b5\'b5\'bd\'c9\'b3\'ba\'d0\'a3\'ac\'b6\'c1\'c8\'a1\'b4\'e6\'b4\'a2\'c9\'be\'b3\'fd\'c9\'b3\'ba\'d0\'bc\'b0\'c6\'ab\'ba\'c3\'c9\'e8\'d6\'c3\'b5\'c4\'ca\'fd\'be\'dd 15 | \f0 \ 16 | 4.LocalPushCenter 17 | \f1 \'a3\'ba\'bf\'ec\'cb\'d9\'ca\'b9\'d3\'c3\'b1\'be\'b5\'d8\'cd\'a8\'d6\'aa 18 | \f0 \ 19 | 5.LXMacro 20 | \f1 \'a3\'ba\'b1\'e3\'c0\'fb\'ba\'ea\'a3\'ac\'b1\'e3\'bd\'dd\'b6\'a8\'d2\'e5@property\'ca\'f4\'d0\'d4 21 | \f0 \ 22 | } -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIView+LFViewIsDisplaying.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+LFViewIsDisplaying.m 3 | // LaiFeng 4 | // 5 | // Created by Ton on 15/12/3. 6 | // Copyright © 2015年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFUIView+LFViewIsDisplaying.h" 10 | 11 | @implementation UIView (LFViewIsDisplayingAdditons) 12 | - (BOOL)lf_isDisplayedInScreen { 13 | if (self == nil) { 14 | return FALSE; 15 | } 16 | 17 | CGRect screenRect = [UIScreen mainScreen].bounds; 18 | 19 | CGRect rect = [self convertRect:self.frame fromView:nil]; 20 | if (CGRectIsEmpty(rect) || CGRectIsNull(rect)) { 21 | return FALSE; 22 | } 23 | 24 | if (self.hidden) { 25 | return FALSE; 26 | } 27 | 28 | if (self.superview == nil) { 29 | return FALSE; 30 | } 31 | 32 | if (CGSizeEqualToSize(rect.size, CGSizeZero)) { 33 | return FALSE; 34 | } 35 | 36 | CGRect intersectionRect = CGRectIntersection(rect, screenRect); 37 | if (CGRectIsEmpty(intersectionRect) || CGRectIsNull(intersectionRect)) { 38 | return FALSE; 39 | } 40 | 41 | return TRUE; 42 | } 43 | @end 44 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSKeyedUnarchiver+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSKeyedUnarchiver+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-8-4. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFNSKeyedUnarchiver+Add.h" 10 | #import "LFCategoryMacro.h" 11 | 12 | 13 | @implementation NSKeyedUnarchiver (LFNSKeyedUnarchiverAdditions) 14 | 15 | + (id)lf_unarchiveObjectWithData:(NSData *)data exception:(__autoreleasing NSException **)exception { 16 | id object = nil; 17 | @try { 18 | object = [NSKeyedUnarchiver unarchiveObjectWithData:data]; 19 | } 20 | @catch (NSException *e) 21 | { 22 | if (exception) *exception = e; 23 | } 24 | @finally 25 | { 26 | } 27 | return object; 28 | } 29 | 30 | + (id)lf_unarchiveObjectWithFile:(NSString *)path exception:(__autoreleasing NSException **)exception { 31 | id object = nil; 32 | 33 | @try { 34 | object = [NSKeyedUnarchiver unarchiveObjectWithFile:path]; 35 | } 36 | @catch (NSException *e) 37 | { 38 | if (exception) *exception = e; 39 | } 40 | @finally 41 | { 42 | } 43 | return object; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIGestureRecognizer+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIGestureRecognizer+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-10-13. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provides extensions for `UIGestureRecognizer`. 13 | */ 14 | @interface UIGestureRecognizer (LFAdditions) 15 | 16 | /** 17 | Initializes an allocated gesture-recognizer object with a action block. 18 | 19 | @param block An action block that to handle the gesture recognized by the 20 | receiver. nil is invalid. It is retained by the gesture. 21 | 22 | @return An initialized instance of a concrete UIGestureRecognizer subclass or 23 | nil if an error occurred in the attempt to initialize the object. 24 | */ 25 | - (instancetype)initWithActionBlock:(void (^)(id sender))block; 26 | 27 | /** 28 | Adds an action block to a gesture-recognizer object. It is retained by the 29 | gesture. 30 | 31 | @param block A block invoked by the action message. nil is not a valid value. 32 | */ 33 | - (void)lf_addActionBlock:(void (^)(id sender))block; 34 | 35 | /** 36 | Remove all action blocks. 37 | */ 38 | - (void)lf_removeAllActionBlocks; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSKeyedUnarchiver+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSKeyedUnarchiver+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-8-4. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provides extensions for `NSKeyedUnarchiver`. 13 | */ 14 | @interface NSKeyedUnarchiver (LFNSKeyedUnarchiverAdditions) 15 | 16 | /** 17 | Same as unarchiveObjectWithData:, except it returns the exception by reference. 18 | 19 | @param data The data need unarchived. 20 | 21 | @param exception Pointer which will, upon return, if an exception occurred and 22 | said pointer is not NULL, point to said NSException. 23 | */ 24 | + (id)lf_unarchiveObjectWithData:(NSData *)data exception:(__autoreleasing NSException **)exception; 25 | 26 | /** 27 | Same as unarchiveObjectWithFile:, except it returns the exception by reference. 28 | 29 | @param path The path of archived object file. 30 | 31 | @param exception Pointer which will, upon return, if an exception occurred and 32 | said pointer is not NULL, point to said NSException. 33 | */ 34 | + (id)lf_unarchiveObjectWithFile:(NSString *)path exception:(__autoreleasing NSException **)exception; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIScrollView+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-5. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provides extensions for `UIScrollView`. 13 | */ 14 | @interface UIScrollView (LFAdditions) 15 | 16 | /** 17 | Scroll content to top with animation. 18 | */ 19 | - (void)lf_scrollToTop; 20 | 21 | /** 22 | Scroll content to bottom with animation. 23 | */ 24 | - (void)lf_scrollToBottom; 25 | 26 | /** 27 | Scroll content to left with animation. 28 | */ 29 | - (void)lf_scrollToLeft; 30 | 31 | /** 32 | Scroll content to right with animation. 33 | */ 34 | - (void)lf_scrollToRight; 35 | 36 | /** 37 | Scroll content to top. 38 | 39 | @param animated Use animation. 40 | */ 41 | - (void)lf_scrollToTopAnimated:(BOOL)animated; 42 | 43 | /** 44 | Scroll content to bottom. 45 | 46 | @param animated Use animation. 47 | */ 48 | - (void)lf_scrollToBottomAnimated:(BOOL)animated; 49 | 50 | /** 51 | Scroll content to left. 52 | 53 | @param animated Use animation. 54 | */ 55 | - (void)lf_scrollToLeftAnimated:(BOOL)animated; 56 | 57 | /** 58 | Scroll content to right. 59 | 60 | @param animated Use animation. 61 | */ 62 | - (void)lf_scrollToRightAnimated:(BOOL)animated; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /textTools/textTools/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSMutableArray+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSMutableArray+Add.h 3 | // LFCategory 4 | // 5 | // Created by WangZhiWei on 16/5/19. 6 | // Copyright © 2016年 youku. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provide some some common method for `NSMutableArray`. 13 | */ 14 | @interface NSMutableArray (LFNSMutableArrayAdditions) 15 | 16 | /// 移除第一个对象 (如果Array空,则无效果) 17 | - (void)lf_removeFirstObject; 18 | 19 | /// 移除最后一个对象 (如果Array空,则无效果) 20 | - (void)lf_removeLastObject; 21 | 22 | /// 移除第一个对象并返回 (如果Array空,则无效果) 23 | - (id)lf_popFirstObject; 24 | 25 | /// 移除最后一个对象并返回 (如果Array空,则无效果) 26 | - (id)lf_popLastObject; 27 | 28 | /// 在结尾添加对象 (不能为nil) 29 | - (void)appendObject:(id)anObject; 30 | 31 | /// 在开头添加对象 (不能为nil) 32 | - (void)lf_prependObject:(id)anObject; 33 | 34 | /// 在结尾添加一批对象 (可以为nil) 35 | - (void)appendObjects:(NSArray *)objects; 36 | 37 | /// 在开头添加一批对象 (可以为nil) 38 | - (void)lf_prependObjects:(NSArray *)objects; 39 | 40 | /// 在某个位置添加一批对象 (index不能超出范围) 41 | - (void)lf_insertObjects:(NSArray *)objects atIndex:(NSUInteger)index; 42 | 43 | /// 反转对象顺序,例如 @[ @1, @2, @3 ] -> @[ @3, @2, @1 ]. 44 | - (void)lf_reverse; 45 | 46 | /// 随机排列对象顺序 (洗牌) 47 | - (void)lf_shuffle; 48 | 49 | /// 添加一个对象,可以为nil。当是NSNull时,不会被添加。 50 | - (void)lf_appendObject:(id)anObject; 51 | 52 | - (void)lf_appendObjects:(NSArray*)objects; 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSArray+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-4. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFNSArray+Add.h" 10 | #import "LFCategoryMacro.h" 11 | 12 | 13 | 14 | @implementation NSArray (LFNSArrayAdditions) 15 | 16 | - (id)lf_randomObject { 17 | if (self.count) { 18 | return self[arc4random_uniform((u_int32_t)self.count)]; 19 | } 20 | return nil; 21 | } 22 | 23 | - (id)lf_objectOrNilAtIndex:(NSUInteger)index { 24 | return index < self.count ? self[index] : nil; 25 | } 26 | 27 | - (NSString *)lf_jsonStringEncoded { 28 | if ([NSJSONSerialization isValidJSONObject:self]) { 29 | NSError *error; 30 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self options:0 error:&error]; 31 | NSString *json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; 32 | return json; 33 | } 34 | return nil; 35 | } 36 | 37 | - (NSString *)lf_jsonPrettyStringEncoded { 38 | if ([NSJSONSerialization isValidJSONObject:self]) { 39 | NSError *error; 40 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self options:NSJSONWritingPrettyPrinted error:&error]; 41 | NSString *json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; 42 | return json; 43 | } 44 | return nil; 45 | } 46 | 47 | @end 48 | 49 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIView+MBProgressHUD.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MBProgressHUD.h 3 | // LFMBProgressHUDDemo 4 | // 5 | // Created by WangZhiWei on 16/5/26. 6 | // Copyright © 2016年 youku. All rights reserved. 7 | // 8 | 9 | #import 10 | @class MBProgressHUD; 11 | 12 | @interface UIView (LFMBProgressHUDAdditions) 13 | 14 | 15 | /*! 16 | @method 17 | @abstract 18 | @discussion 显示转菊花 19 | @param animated 20 | @result 21 | */ 22 | - (void)lf_showHUDAnimated:(BOOL)animated; 23 | 24 | 25 | 26 | /*! 27 | @method 28 | @abstract 29 | @discussion 显示消息 30 | @param animated 31 | @param message 消息内容 32 | @result 33 | */ 34 | - (void)lf_showHUDAnimated:(BOOL)animated message:(NSString *)message; 35 | 36 | /*! 37 | @method 38 | @abstract 39 | @discussion 40 | @param animated 41 | @param message 消息内容 42 | @param time 延迟时间 43 | @result 44 | */ 45 | - (MBProgressHUD *)lf_showHUDAnimated:(BOOL)animated message:(NSString *)message dalayTime:(NSTimeInterval)time; 46 | 47 | /*! 48 | @method 49 | @abstract 50 | @discussion 51 | @param image 52 | @param animated 53 | @param message 消息内容 54 | @param time 延迟时间 55 | @result 56 | */ 57 | - (void)lf_showHUDMessage:(NSString *)message imageNamed:(NSString *)image animated:(BOOL)animated dalay:(NSTimeInterval)time; 58 | 59 | 60 | /*! 61 | @method 62 | @abstract 63 | @discussion 删除 64 | @param animated 65 | @result 66 | */ 67 | - (void)lf_removeAllHUDAnimated:(BOOL)animated; 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIBarButtonItem+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-10-15. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFUIBarButtonItem+Add.h" 10 | #import "LFCategoryMacro.h" 11 | #import 12 | 13 | 14 | static const int block_key; 15 | 16 | @interface _LFUIBarButtonItemBlockTarget : NSObject 17 | 18 | @property (nonatomic, copy) void (^block)(id sender); 19 | 20 | - (id)initWithBlock:(void (^)(id sender))block; 21 | - (void)invoke:(id)sender; 22 | 23 | @end 24 | 25 | @implementation _LFUIBarButtonItemBlockTarget 26 | 27 | - (id)initWithBlock:(void (^)(id sender))block{ 28 | self = [super init]; 29 | if (self) { 30 | self.block = block; 31 | } 32 | return self; 33 | } 34 | 35 | - (void)invoke:(id)sender { 36 | if (self.block) self.block(sender); 37 | } 38 | 39 | @end 40 | 41 | 42 | @implementation UIBarButtonItem (LFAdditions) 43 | 44 | - (void)setActionBlock:(void (^)(id sender))block { 45 | _LFUIBarButtonItemBlockTarget *target = [[_LFUIBarButtonItemBlockTarget alloc] initWithBlock:block]; 46 | objc_setAssociatedObject(self, &block_key, target, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 47 | 48 | [self setTarget:target]; 49 | [self setAction:@selector(invoke:)]; 50 | } 51 | 52 | - (void (^)(id)) actionBlock { 53 | _LFUIBarButtonItemBlockTarget *target = objc_getAssociatedObject(self, &block_key); 54 | return target.block; 55 | } 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /textTools/工具类分享/2/HelperUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // HelperUtil.h 3 | // SQLite(购物) 4 | // 5 | // Created by Yock Deng on 15/8/22. 6 | // Copyright (c) 2015年 蓝桥. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface HelperUtil : NSObject 13 | 14 | + (NSString *)htmlShuangyinhao:(NSString *)values; 15 | + (UIColor *) colorWithHexString: (NSString *) stringToConvert; 16 | + (NSString *) nullDefultString: (NSString *)fromString null:(NSString *)nullStr; 17 | 18 | #pragma 正则匹配邮箱号 19 | + (BOOL)checkMailInput:(NSString *)mail; 20 | #pragma 正则匹配手机号 21 | + (BOOL)checkTelNumber:(NSString *) telNumber; 22 | #pragma 正则匹配用户密码6-18位数字和字母组合 23 | + (BOOL)checkPassword:(NSString *) password; 24 | #pragma 正则匹配用户姓名,20位的中文或英文 25 | + (BOOL)checkUserName : (NSString *) userName; 26 | #pragma 正则匹配用户身份证号 27 | + (BOOL)checkUserIdCard: (NSString *) idCard; 28 | #pragma 正则匹员工号,12位的数字 29 | + (BOOL)checkEmployeeNumber : (NSString *) number; 30 | #pragma 正则匹配URL 31 | + (BOOL)checkURL : (NSString *) url; 32 | #pragma 正则匹配昵称 33 | + (BOOL) checkNickname:(NSString *) nickname; 34 | #pragma 正则匹配以C开头的18位字符 35 | + (BOOL) checkCtooNumberTo18:(NSString *) nickNumber; 36 | #pragma 正则匹配以C开头字符 37 | + (BOOL) checkCtooNumber:(NSString *) nickNumber; 38 | #pragma 正则匹配银行卡号是否正确 39 | + (BOOL) checkBankNumber:(NSString *) bankNumber; 40 | #pragma 正则匹配17位车架号 41 | + (BOOL) checkCheJiaNumber:(NSString *) CheJiaNumber; 42 | #pragma 正则只能输入数字和字母 43 | + (BOOL) checkTeshuZifuNumber:(NSString *) CheJiaNumber; 44 | #pragma 车牌号验证 45 | + (BOOL) checkCarNumber:(NSString *) CarNumber; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /textTools/工具类分享/1/Single.h: -------------------------------------------------------------------------------- 1 | // 2 | // Single.h 3 | // Entertainer 4 | // 5 | // Created by funeral on 15/10/5. 6 | // Copyright © 2015年 funeral. All rights reserved. 7 | // 8 | 9 | #ifndef Single_h 10 | #define Single_h 11 | 12 | #ifdef __OBJC__ 13 | 14 | #pragma mark - 单例模式 .h文件内容 15 | #define SingleInterface(name) +(instancetype)share##name; 16 | 17 | 18 | #pragma mark - 单例模式 .m文件内容 19 | #if __has_feature(objc_arc) 20 | #define SingleImplementation(name) +(instancetype)share##name {return [[self alloc]init];} \ 21 | + (instancetype)allocWithZone:(struct _NSZone *)zone { \ 22 | static id instance; \ 23 | static dispatch_once_t onceToken; \ 24 | dispatch_once(&onceToken, ^{ \ 25 | instance = [super allocWithZone:zone]; \ 26 | }); \ 27 | return instance; \ 28 | } \ 29 | - (id)copyWithZone:(NSZone *)zone{return self;} \ 30 | - (id)mutableCopyWithZone:(NSZone *)zone {return self;} 31 | 32 | #else 33 | 34 | #define SingleImplementation(name) +(instancetype)share##name {return [[self alloc]init];} \ 35 | + (instancetype)allocWithZone:(struct _NSZone *)zone { \ 36 | static id instance; \ 37 | static dispatch_once_t onceToken; \ 38 | dispatch_once(&onceToken, ^{ \ 39 | instance = [super allocWithZone:zone]; \ 40 | }); \ 41 | return instance; \ 42 | } \ 43 | - (id)copyWithZone:(NSZone *)zone{return self;} \ 44 | - (id)mutableCopyWithZone:(NSZone *)zone {return self;} \ 45 | - (instancetype)retain {return self;} \ 46 | - (instancetype)autorelease {return self;} \ 47 | - (oneway void)release {} \ 48 | - (NSUInteger)retainCount {return MAXFLOAT;} \ 49 | 50 | #endif 51 | 52 | #endif 53 | 54 | #endif /* Single_h */ 55 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSObject+AddForKVO.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+LFAddForKVO.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-10-15. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Observer with block (KVO). 13 | */ 14 | @interface NSObject (LFAddForKVO) 15 | 16 | /** 17 | Registers a block to receive KVO notifications for the specified key-path 18 | relative to the receiver. 19 | 20 | @discussion The block and block captured objects are retained. Call 21 | `removeObserverBlocksForKeyPath:` or `removeObserverBlocks` to release. 22 | 23 | @param keyPath The key path, relative to the receiver, of the property to 24 | observe. This value must not be nil. 25 | 26 | @param block The block to register for KVO notifications. 27 | */ 28 | - (void)lf_addObserverBlockForKeyPath:(NSString*)keyPath block:(void (^)(id obj, id oldVal, id newVal))block; 29 | 30 | /** 31 | Stops all blocks (associated by `addObserverBlockForKeyPath:block:`) from 32 | receiving change notifications for the property specified by a given key-path 33 | relative to the receiver, and release these blocks. 34 | 35 | @param keyPath A key-path, relative to the receiver, for which blocks is 36 | registered to receive KVO change notifications. 37 | */ 38 | - (void)lf_removeObserverBlocksForKeyPath:(NSString*)keyPath; 39 | 40 | /** 41 | Stops all blocks (associated by `addObserverBlockForKeyPath:block:`) from 42 | receiving change notifications, and release these blocks. 43 | */ 44 | - (void)lf_removeObserverBlocks; 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIScrollView+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIScrollView+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-5. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFUIScrollView+Add.h" 10 | #import "LFCategoryMacro.h" 11 | 12 | 13 | @implementation UIScrollView (LFAdditions) 14 | 15 | - (void)lf_scrollToTop { 16 | [self lf_scrollToTopAnimated:YES]; 17 | } 18 | 19 | - (void)lf_scrollToBottom { 20 | [self lf_scrollToBottomAnimated:YES]; 21 | } 22 | 23 | - (void)lf_scrollToLeft { 24 | [self lf_scrollToLeftAnimated:YES]; 25 | } 26 | 27 | - (void)lf_scrollToRight { 28 | [self lf_scrollToRightAnimated:YES]; 29 | } 30 | 31 | - (void)lf_scrollToTopAnimated:(BOOL)animated { 32 | CGPoint off = self.contentOffset; 33 | off.y = 0 - self.contentInset.top; 34 | [self setContentOffset:off animated:animated]; 35 | } 36 | 37 | - (void)lf_scrollToBottomAnimated:(BOOL)animated { 38 | CGPoint off = self.contentOffset; 39 | off.y = self.contentSize.height - self.bounds.size.height + self.contentInset.bottom; 40 | [self setContentOffset:off animated:animated]; 41 | } 42 | 43 | - (void)lf_scrollToLeftAnimated:(BOOL)animated { 44 | CGPoint off = self.contentOffset; 45 | off.x = 0 - self.contentInset.left; 46 | [self setContentOffset:off animated:animated]; 47 | } 48 | 49 | - (void)lf_scrollToRightAnimated:(BOOL)animated { 50 | CGPoint off = self.contentOffset; 51 | off.x = self.contentSize.width - self.bounds.size.width + self.contentInset.right; 52 | [self setContentOffset:off animated:animated]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFWeakProxy.m: -------------------------------------------------------------------------------- 1 | // 2 | // LFWeakProxy.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 14/10/18. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFWeakProxy.h" 10 | 11 | 12 | @implementation LFWeakProxy 13 | 14 | - (instancetype)initWithTarget:(id)target { 15 | _target = target; 16 | return self; 17 | } 18 | 19 | + (instancetype)proxyWithTarget:(id)target { 20 | return [[LFWeakProxy alloc] initWithTarget:target]; 21 | } 22 | 23 | - (id)forwardingTargetForSelector:(SEL)selector { 24 | return _target; 25 | } 26 | 27 | - (void)forwardInvocation:(NSInvocation *)invocation { 28 | void *null = NULL; 29 | [invocation setReturnValue:&null]; 30 | } 31 | 32 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector { 33 | return [NSObject instanceMethodSignatureForSelector:@selector(init)]; 34 | } 35 | 36 | - (NSString *)description { 37 | return [_target description]; 38 | } 39 | 40 | - (NSString *)debugDescription { 41 | return [_target debugDescription]; 42 | } 43 | 44 | - (BOOL)respondsToSelector:(SEL)aSelector { 45 | return [_target respondsToSelector:aSelector]; 46 | } 47 | 48 | - (Class)class { 49 | return [_target class]; 50 | } 51 | 52 | - (BOOL)isKindOfClass:(Class)aClass { 53 | return [_target isKindOfClass:aClass]; 54 | } 55 | 56 | - (BOOL)isMemberOfClass:(Class)aClass { 57 | return [_target isMemberOfClass:aClass]; 58 | } 59 | 60 | - (BOOL)conformsToProtocol:(Protocol *)aProtocol { 61 | return [_target conformsToProtocol:aProtocol]; 62 | } 63 | 64 | - (BOOL)isProxy { 65 | return YES; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUITableViewCell+LFCellMethodExtend.m: -------------------------------------------------------------------------------- 1 | // 2 | // UITableViewCell+LFCellMethodExtend.m 3 | // LaiFeng 4 | // 5 | // Created by Ton on 15/9/11. 6 | // Copyright (c) 2015年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFUITableViewCell+LFCellMethodExtend.h" 10 | #import "LFCategory.h" 11 | 12 | @implementation UITableViewCell (LFCellMethodExtendAdditions) 13 | 14 | + (id)lf_loadFromXib { 15 | 16 | return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:self options:nil]lastObject]; 17 | } 18 | 19 | + (NSString*)lf_cellIdentifier { 20 | 21 | return NSStringFromClass(self); 22 | } 23 | 24 | + (id)lf_loadFromCellStyle:(UITableViewCellStyle)cellStyle { 25 | 26 | return [[self alloc] initWithStyle:cellStyle reuseIdentifier:NSStringFromClass(self)]; 27 | } 28 | 29 | 30 | - (void)lf_createSeparatorOfView:(UIView *)view Direction:(UIViewSeparatorDirection)direction edgeNum:(float)edgeNum { 31 | if (view == nil) { 32 | return; 33 | } 34 | UIView *separatorView = UIView.new; 35 | separatorView.backgroundColor = [UIColor lightGrayColor]; 36 | 37 | if (edgeNum) { 38 | [separatorView setFrame:CGRectMake(edgeNum, 0, self.lf_width-edgeNum, .5f)]; 39 | } 40 | else { 41 | [separatorView setFrame:CGRectMake(0, 0, self.lf_width, .5f)]; 42 | } 43 | CGRect frame = separatorView.frame; 44 | if (direction == UIViewSeparatorDirectionTop) { 45 | frame.origin.y = 0; 46 | } 47 | else { 48 | frame.origin.y = frame.size.height - .5f; 49 | } 50 | separatorView.frame = frame; 51 | [view addSubview:separatorView]; 52 | } 53 | @end 54 | -------------------------------------------------------------------------------- /textTools/textTools/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /textTools/分类分享/NSDictionary+PropertyCode/NSDictionary+PropertyCode.m: -------------------------------------------------------------------------------- 1 | 2 | #import "NSDictionary+PropertyCode.h" 3 | 4 | @implementation NSDictionary (PropertyCode) 5 | 6 | // isKindOfClass:判断下是否是当前类或者子类 7 | // @property (nonatomic ,strong) NSString *text; 8 | // @property (nonatomic ,assign) NSInteger reposts_count; 9 | // @property (nonatomic ,assign) NSArray *pic_urls; 10 | - (void)propertyCode 11 | { 12 | 13 | // 属性跟字典的key一一对应 14 | NSMutableString *codes = [NSMutableString string]; 15 | // 遍历字典中所有key取出来 16 | [self enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { 17 | // key:属性名 18 | NSString *code; 19 | if ([obj isKindOfClass:[NSString class]]) { 20 | code = [NSString stringWithFormat:@"@property (nonatomic ,strong) NSString *%@;",key]; 21 | }else if ([obj isKindOfClass:NSClassFromString(@"__NSCFBoolean")]){ 22 | code = [NSString stringWithFormat:@"@property (nonatomic ,assign) BOOL %@;",key]; 23 | }else if ([obj isKindOfClass:[NSNumber class]]){ 24 | code = [NSString stringWithFormat:@"@property (nonatomic ,assign) NSInteger %@;",key]; 25 | }else if ([obj isKindOfClass:[NSArray class]]){ 26 | code = [NSString stringWithFormat:@"@property (nonatomic ,strong) NSArray *%@;",key]; 27 | }else if ([obj isKindOfClass:[NSDictionary class]]){ 28 | code = [NSString stringWithFormat:@"@property (nonatomic ,strong) NSDictionary *%@;",key]; 29 | } 30 | 31 | 32 | 33 | [codes appendFormat:@"\n%@\n",code]; 34 | 35 | }]; 36 | 37 | NSLog(@"%@",codes); 38 | 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /textTools/工具类分享/3/LXFileManager.m: -------------------------------------------------------------------------------- 1 | 2 | #import "LXFileManager.h" 3 | 4 | @implementation LXFileManager 5 | 6 | /// 把对象归档存到沙盒里 7 | +(void)saveObject:(id)object byFileName:(NSString*)fileName 8 | { 9 | NSString *path = [self appendFilePath:fileName]; 10 | 11 | [NSKeyedArchiver archiveRootObject:object toFile:path]; 12 | 13 | } 14 | /// 通过文件名从沙盒中找到归档的对象 15 | +(id)getObjectByFileName:(NSString*)fileName 16 | { 17 | 18 | NSString *path = [self appendFilePath:fileName]; 19 | 20 | return [NSKeyedUnarchiver unarchiveObjectWithFile:path]; 21 | } 22 | 23 | // 根据文件名删除沙盒中的 plist 文件 24 | +(void)removeFileByFileName:(NSString*)fileName 25 | { 26 | NSString *path = [self appendFilePath:fileName]; 27 | 28 | [[NSFileManager defaultManager] removeItemAtPath:path error:nil]; 29 | } 30 | 31 | /// 拼接文件路径 32 | +(NSString*)appendFilePath:(NSString*)fileName 33 | { 34 | 35 | NSString *documentsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; 36 | 37 | NSString *file = [NSString stringWithFormat:@"%@/%@.archiver",documentsPath,fileName]; 38 | 39 | return file; 40 | } 41 | 42 | /// 存储用户偏好设置 到 NSUserDefults 43 | +(void)saveUserData:(id)data forKey:(NSString*)key 44 | { 45 | if (data) 46 | { 47 | [[NSUserDefaults standardUserDefaults]setObject:data forKey:key]; 48 | [[NSUserDefaults standardUserDefaults]synchronize]; 49 | } 50 | } 51 | /// 读取用户偏好设置 52 | +(id)readUserDataForKey:(NSString*)key 53 | { 54 | return [[NSUserDefaults standardUserDefaults]objectForKey:key]; 55 | 56 | } 57 | /// 删除用户偏好设置 58 | +(void)removeUserDataForkey:(NSString*)key 59 | { 60 | [[NSUserDefaults standardUserDefaults]removeObjectForKey:key]; 61 | } 62 | 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFALAsset+Property.m: -------------------------------------------------------------------------------- 1 | // 2 | // ALAsset+LFAdd.m 3 | // LaiFeng 4 | // 5 | // Created by liuxin on 15/1/12. 6 | // Copyright (c) 2015年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFALAsset+Property.h" 10 | 11 | 12 | @implementation ALAsset (LFALAssetPopertyAdditions) 13 | 14 | 15 | 16 | // 图片资源唯一的标示 17 | - (NSString *)lf_uniqueId 18 | { 19 | return [NSString stringWithFormat:@"%@%f", [self uniqueFileName], [self lf_timeIntervalSince1970]]; 20 | } 21 | 22 | // 比较两个图片资源指向的对象是否相等 23 | - (BOOL)lf_isEqual:(id)other 24 | { 25 | if (other == self) 26 | return YES; 27 | 28 | if (!other || ![other isKindOfClass:[self class]]) 29 | return NO; 30 | 31 | if (self.lf_timeIntervalSince1970 == ((ALAsset *)other).lf_timeIntervalSince1970) { // 比较拍摄时间 32 | NSString* selfUniqueFileName = self.uniqueFileName; 33 | NSString* otherUniqueFileName = ((ALAsset *)other).uniqueFileName; 34 | return [selfUniqueFileName isEqualToString:otherUniqueFileName]; // 比较文件名 35 | } 36 | 37 | return NO; 38 | } 39 | 40 | // 唯一图片资源的文件名 41 | - (NSString *)uniqueFileName 42 | { 43 | NSString *path = [self defaultRepresentation].url.relativeString; 44 | NSArray *pathList = [path componentsSeparatedByString: @"/"]; 45 | NSString *filteName = (NSString *)[pathList lastObject]; 46 | return filteName; 47 | } 48 | 49 | // 图片属性日期 50 | - (NSDate *)propertyDate 51 | { 52 | NSDate * date = [self valueForProperty:ALAssetPropertyDate]; 53 | return [date copy]; 54 | } 55 | 56 | // 图片资源的拍摄时间 57 | - (NSTimeInterval)lf_timeIntervalSince1970 58 | { 59 | NSDate * date = [self valueForProperty:ALAssetPropertyDate]; 60 | return [date timeIntervalSince1970]; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSNumber+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNumber+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-8-24. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFNSNumber+Add.h" 10 | #import "LFNSString+Add.h" 11 | #import "LFCategoryMacro.h" 12 | 13 | 14 | @implementation NSNumber (LFAdditions) 15 | 16 | + (NSNumber *)lf_numberWithString:(NSString *)string { 17 | NSString *str = [[string lf_stringByTrim] lowercaseString]; 18 | if (!str || !str.length) { 19 | return nil; 20 | } 21 | 22 | // hex number 23 | int sign = 0; 24 | if ([str hasPrefix:@"0x"]) sign = 1; 25 | else if ([str hasPrefix:@"-0x"]) sign = -1; 26 | if (sign != 0) { 27 | NSScanner *scan = [NSScanner scannerWithString:str]; 28 | unsigned num = -1; 29 | BOOL suc = [scan scanHexInt:&num]; 30 | if (suc) 31 | return [NSNumber numberWithLong:((long)num * sign)]; 32 | else 33 | return nil; 34 | } 35 | 36 | // normal number 37 | NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; 38 | [formatter setNumberStyle:NSNumberFormatterDecimalStyle]; 39 | return [formatter numberFromString:string]; 40 | } 41 | 42 | - (NSString *)lf_wrappedDescription { 43 | if (self.longLongValue <= 9999) { 44 | return self.description; 45 | } else { 46 | return [NSString stringWithFormat:@"%.1f万",(self.longLongValue)/(10000.0)]; 47 | } 48 | } 49 | 50 | 51 | - (NSString *)lf_toDecimalStyleString 52 | { 53 | NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; 54 | numberFormatter.numberStyle = NSNumberFormatterDecimalStyle; 55 | return [numberFormatter stringFromNumber:self]; 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSDate+Property.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-11. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provides extensions for `NSDate`. 13 | */ 14 | @interface NSDate (LFPropertyAdditions) 15 | 16 | 17 | #pragma mark - 时间部分 18 | ///============================================================================= 19 | /// @name 时间部分 20 | ///============================================================================= 21 | 22 | @property (nonatomic, readonly) NSInteger lf_year; ///< Year component 23 | @property (nonatomic, readonly) NSInteger lf_month; ///< Month component 24 | @property (nonatomic, readonly) NSInteger lf_day; ///< Day component 25 | @property (nonatomic, readonly) NSInteger lf_hour; ///< Hour component 26 | @property (nonatomic, readonly) NSInteger lf_minute; ///< Minute component 27 | @property (nonatomic, readonly) NSInteger lf_second; ///< Second component 28 | @property (nonatomic, readonly) NSInteger lf_nanosecond; ///< Nanosecond component 29 | @property (nonatomic, readonly) NSInteger lf_weekday; ///< Weekday component 30 | @property (nonatomic, readonly) NSInteger lf_weekdayOrdinal; ///< WeekdayOrdinal component 31 | @property (nonatomic, readonly) NSInteger lf_weekOfMonth; ///< WeekOfMonth component 32 | @property (nonatomic, readonly) NSInteger lf_weekOfYear; ///< WeekOfYear component 33 | @property (nonatomic, readonly) NSInteger lf_yearForWeekOfYear; ///< YearForWeekOfYear component 34 | @property (nonatomic, readonly) NSInteger lf_quarter; ///< Quarter component 35 | @property (nonatomic, readonly) BOOL lf_isLeapMonth; ///< 是否闰月 36 | @property (nonatomic, readonly) BOOL lf_isLeapYear; ///< 是否闰年 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /textTools/textTools/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSDate+Format.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+Format.h 3 | // LFCategory 4 | // 5 | // Created by WangZhiWei on 16/5/19. 6 | // Copyright © 2016年 youku. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSDate (LFFormatAdditions) 12 | 13 | #pragma mark - 日期格式化 14 | ///============================================================================= 15 | /// @name 日期格式化 16 | ///============================================================================= 17 | 18 | /** 19 | 将日期格式化成字符串 20 | 支持格式:http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns 21 | @param format 格式,例如 @"yyyy-MM-dd HH:mm:ss" 22 | */ 23 | - (NSString *)lf_stringWithFormat:(NSString *)format; 24 | 25 | /** 26 | 将日期格式化成字符串 27 | 支持格式:http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns 28 | @param format 格式,例如 @"yyyy-MM-dd HH:mm:ss" 29 | */ 30 | - (NSString *)lf_stringWithFormat:(NSString *)format timeZone:(NSTimeZone *)timeZone locale:(NSLocale *)locale; 31 | 32 | /** 33 | 以 ISO8601 格式化日期。例如: "2010-07-09T16:13:30+12:00" 34 | */ 35 | - (NSString *)lf_stringWithISOFormat; 36 | 37 | /** 38 | 从字符串解析出日期 (解析失败则返回nil) 39 | @param dateString 日期字符串,例如 "2010-07-09 16:13:30" 40 | @param format 日期格式,例如 "yyyy-MM-dd HH:mm:ss" 41 | */ 42 | + (NSDate *)lf_dateWithString:(NSString *)dateString format:(NSString *)format; 43 | 44 | /** 45 | 从字符串解析出日期 (解析失败则返回nil) 46 | @param dateString 日期字符串,例如 "2010-07-09 16:13:30" 47 | @param format 日期格式,例如 "yyyy-MM-dd HH:mm:ss" 48 | */ 49 | + (NSDate *)lf_dateWithString:(NSString *)dateString format:(NSString *)format timeZone:(NSTimeZone *)timeZone locale:(NSLocale *)locale; 50 | 51 | /** 52 | 将 ISO8601 格式的字符串解析成日期。 53 | @param dateString 时间字符串,例如 "2010-07-09T16:13:30+12:00" 54 | */ 55 | + (NSDate *)lf_dateWithISOFormatString:(NSString *)dateString; 56 | 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSDictionary+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-4. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | FOUNDATION_STATIC_INLINE BOOL NSDictionaryIsEmpty(NSDictionary *dictionary) 12 | { 13 | if (dictionary && dictionary.count > 0 ) return NO; 14 | 15 | return YES; 16 | } 17 | 18 | /** 19 | Provide some some common method for `NSDictionary`. 20 | */ 21 | @interface NSDictionary (LFNSDictionaryAdditions) 22 | 23 | /// 返回所有key (按字典序排列) 24 | - (NSArray *)lf_allKeysSorted; 25 | 26 | /// 返回所有value (按key的字典序排列) 27 | - (NSArray *)lf_allValuesSortedByKeys; 28 | 29 | /// 是否包含 key 30 | - (BOOL)lf_containsObjectForKey:(id)key; 31 | 32 | /// 根据一组 key 来取对象 33 | - (NSDictionary *)lf_entriesForKeys:(NSArray *)keys; 34 | 35 | /// 编码为 json 字符串。 如果出错则返回nil。 内容支持NSString/NSNumber/NSDictionary/NSArray 36 | - (NSString *)lf_jsonStringEncoded; 37 | 38 | /// 编码为 json 字符串(带格式)。 如果出错则返回nil。 内容支持NSString/NSNumber/NSDictionary/NSArray 39 | - (NSString *)lf_jsonPrettyStringEncoded; 40 | 41 | /** 42 | 尝试解析 XML,并包装为 dictionary。 43 | 如果你只是想从一个小xml里取一个值,可以试试这个方法 44 | 45 | example XML: "link" 46 | example Return: @{@"_name":@"config", @"a":{@"_text":@"link",@"href":@"test.com"}} 47 | 48 | @param xmlDataOrString XML in NSData or NSString format. 49 | 50 | @return Return a new dictionary, or nil if an error occurs. 51 | */ 52 | + (NSDictionary *)lf_dictionaryWithXML:(id)xmlDataOrString; 53 | 54 | @end 55 | 56 | 57 | 58 | /** 59 | Provide some some common method for `NSMutableDictionary`. 60 | */ 61 | @interface NSMutableDictionary (LFNSMutableDictionaryAdditions) 62 | 63 | /// 移除并返回一个对象 64 | - (id)lf_popObjectForKey:(id)aKey; 65 | 66 | /// 移除并返回一组对象 67 | - (NSDictionary *)lf_popEntriesForKeys:(NSArray *)keys; 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /textTools/textTools/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // textTools 4 | // 5 | // Created by Lee on 16/6/25. 6 | // Copyright © 2016年 Lee. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIImage+Resource.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+Resource.m 3 | // LaiFeng 4 | // 5 | // Created by xinliu on 14-4-24. 6 | // Copyright (c) 2014年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFUIImage+Resource.h" 10 | #import "LFNSBundle+Add.h" 11 | #import "LFNSString+Add.h" 12 | 13 | 14 | 15 | 16 | 17 | #define LFImagePath(name) [NSString stringWithFormat:@"skin_common.bundle/Images/%@",(name)] 18 | 19 | #define LFEmotionPath(name) [NSString stringWithFormat:@"skin_common.bundle/Images/emotions/%@",(name)] 20 | 21 | @implementation UIImage(LFResourceAdditions) 22 | 23 | + (UIImage *)lf_EmotionWithName:(NSString *)name 24 | { 25 | //Debug OK 26 | NSString* imagePath = LFEmotionPath(name); 27 | UIImage* emotion = [UIImage imageNamed:imagePath]; 28 | return emotion; 29 | } 30 | 31 | 32 | + (UIImage *)lf_imageForKey:(id)key inBundle:(NSBundle *)bundle 33 | { 34 | NSString *imagePath = [bundle lf_pathForScaledResource:key ofType:@"png" inDirectory:@"Images"]; 35 | if (!imagePath) imagePath = [bundle lf_pathForScaledResource:key ofType:@"jpg" inDirectory:@"Images"]; 36 | 37 | if (imagePath) { 38 | NSData *data = [NSData dataWithContentsOfFile:imagePath]; 39 | return [UIImage imageWithData:data scale:imagePath.lf_pathScale]; 40 | } else 41 | { 42 | imagePath = [bundle pathForResource:key ofType:@"png" inDirectory:@"Images/emotions"]; 43 | if(imagePath) { 44 | return [UIImage imageWithContentsOfFile:imagePath]; 45 | } 46 | } 47 | imagePath = [bundle pathForResource:key ofType:@"jpg" inDirectory:@"Images"]; 48 | if (imagePath) { 49 | return [UIImage imageWithContentsOfFile:imagePath]; 50 | } 51 | 52 | if ( [key isKindOfClass:[NSString class]] ) { 53 | NSString *key2x = [key stringByAppendingString:@"@2x"]; 54 | if ( [bundle pathForResource:key2x ofType:@"png"] 55 | || [bundle pathForResource:key2x ofType:@"jpg"] ) { 56 | NSLog(@"ERROR: No 1x image resource (low resolution) provided for key:%@, only have 2x image.",key); 57 | } 58 | } 59 | return nil; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUINavigationController+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // UINavigationController+LFAdd.m 3 | // LaiFeng 4 | // 5 | // Created by limingchen on 15/3/2. 6 | // Copyright (c) 2015年 youku&tudou. All rights reserved. 7 | // 8 | 9 | #import "LFUINavigationController+Add.h" 10 | 11 | @implementation UINavigationController (LFAdditions) 12 | 13 | - (void)lf_pushViewController: (UIViewController*)controller 14 | animatedWithTransition: (UIViewAnimationTransition)transition { 15 | [self pushViewController:controller animated:NO]; 16 | 17 | [UIView beginAnimations:nil context:nil]; 18 | [UIView setAnimationDuration:0.5]; 19 | [UIView setAnimationDelegate:nil]; 20 | [UIView setAnimationDidStopSelector:@selector(pushAnimationDidStop)]; 21 | [UIView setAnimationTransition:transition forView:self.view cache:YES]; 22 | [UIView commitAnimations]; 23 | } 24 | 25 | - (UIViewController*)lf_popViewControllerAnimatedWithTransition:(UIViewAnimationTransition)transition { 26 | UIViewController* poppedController = [self popViewControllerAnimated:NO]; 27 | 28 | [UIView beginAnimations:nil context:NULL]; 29 | [UIView setAnimationDuration:0.5]; 30 | [UIView setAnimationDelegate:nil]; 31 | [UIView setAnimationDidStopSelector:@selector(pushAnimationDidStop)]; 32 | [UIView setAnimationTransition:transition forView:self.view cache:NO]; 33 | [UIView commitAnimations]; 34 | 35 | return poppedController; 36 | } 37 | 38 | - (void)pushAnimationDidStop 39 | { 40 | 41 | } 42 | 43 | // ios6以下 44 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 45 | { 46 | return interfaceOrientation == UIInterfaceOrientationPortrait; 47 | } 48 | 49 | // ios6以上 50 | - (NSUInteger)supportedInterfaceOrientations 51 | { 52 | return UIInterfaceOrientationMaskPortrait; 53 | } 54 | 55 | 56 | - (BOOL)shouldAutorotate 57 | { 58 | return NO; 59 | } 60 | 61 | - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation 62 | { 63 | return UIInterfaceOrientationPortrait; 64 | } 65 | 66 | - (UIViewController *)childViewControllerForStatusBarStyle 67 | { 68 | return self.topViewController; 69 | } 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /textTools/分类分享/UIView+LXExtension/UIView+LXExtension.m: -------------------------------------------------------------------------------- 1 | 2 | #import "UIView+LXExtension.h" 3 | 4 | @implementation UIView (LXExtension) 5 | - (BOOL)lx_intersectsWithView:(UIView *)view 6 | { 7 | //都先转换为相对于窗口的坐标,然后进行判断是否重合 8 | CGRect selfRect = [self convertRect:self.bounds toView:nil]; 9 | CGRect viewRect = [view convertRect:view.bounds toView:nil]; 10 | return CGRectIntersectsRect(selfRect, viewRect); 11 | } 12 | 13 | + (instancetype)lx_viewFromXib 14 | { 15 | 16 | return [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil].firstObject; 17 | } 18 | 19 | - (CGFloat)lx_centerX 20 | { 21 | return self.center.x; 22 | } 23 | - (void)setLx_centerX:(CGFloat)lx_centerX 24 | { 25 | CGPoint center = self.center; 26 | center.x = lx_centerX; 27 | self.center = center; 28 | } 29 | - (CGFloat)lx_centerY 30 | { 31 | return self.center.y; 32 | } 33 | - (void)setLx_centerY:(CGFloat)lx_centerY 34 | { 35 | CGPoint center = self.center; 36 | center.y = lx_centerY; 37 | self.center = center; 38 | } 39 | - (CGSize)lx_size 40 | { 41 | return self.frame.size; 42 | } 43 | 44 | - (void)setLx_size:(CGSize)lx_size 45 | { 46 | CGRect frame = self.frame; 47 | frame.size = lx_size; 48 | self.frame = frame; 49 | } 50 | 51 | - (CGFloat)lx_width 52 | { 53 | return self.frame.size.width; 54 | } 55 | 56 | - (CGFloat)lx_height 57 | { 58 | return self.frame.size.height; 59 | } 60 | 61 | - (void)setLx_width:(CGFloat)lx_width 62 | { 63 | CGRect frame = self.frame; 64 | frame.size.width = lx_width; 65 | self.frame = frame; 66 | } 67 | - (void)setLx_height:(CGFloat)lx_height 68 | { 69 | CGRect frame = self.frame; 70 | frame.size.height = lx_height; 71 | self.frame = frame; 72 | } 73 | 74 | - (CGFloat)lx_x 75 | { 76 | return self.frame.origin.x; 77 | } 78 | 79 | - (void)setLx_x:(CGFloat)lx_x 80 | { 81 | CGRect frame = self.frame; 82 | frame.origin.x = lx_x; 83 | self.frame = frame; 84 | } 85 | 86 | - (CGFloat)lx_y 87 | { 88 | return self.frame.origin.y; 89 | } 90 | 91 | - (void)setLx_y:(CGFloat)lx_y 92 | { 93 | CGRect frame = self.frame; 94 | frame.origin.y = lx_y; 95 | self.frame = frame; 96 | } 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFCategory.h: -------------------------------------------------------------------------------- 1 | // 2 | // LFCategory.h 3 | // LaiFeng 4 | // 5 | // Created by guoyaoyuan on 14/12/2. 6 | // Copyright (c) 2014年 live Interactive. All rights reserved. 7 | // 8 | 9 | #ifndef LaiFeng_LFCategory_h 10 | #define LaiFeng_LFCategory_h 11 | 12 | /* 13 | Laifeng的所有Category。 14 | 可以被引入全局的 pch 文件。 15 | 尽量避免有其他依赖。 16 | */ 17 | 18 | 19 | // Macro 20 | #import "LFCategoryMacro.h" 21 | 22 | 23 | //Foundation 24 | #import "LFALAsset+Property.h" 25 | #import "LFALAsset+Image.h" 26 | #import "LFNSArray+Add.h" 27 | #import "LFNSBundle+Add.h" 28 | #import "LFNSCharacterSet+Add.h" 29 | #import "LFNSData+Add.h" 30 | #import "LFNSDate+Property.h" 31 | #import "LFNSDate+Update.h" 32 | #import "LFNSDate+Format.h" 33 | #import "LFNSDate+Ext.h" 34 | #import "LFNSDictionary+Add.h" 35 | #import "LFNSDictionary+ModelValue.h" 36 | #import "LFNSKeyedUnarchiver+Add.h" 37 | #import "LFNSNotificationCenter+Add.h" 38 | #import "LFNSNumber+Add.h" 39 | #import "LFNSObject+Add.h" 40 | #import "LFNSObject+AddForKVO.h" 41 | #import "LFNSObject+AddForNotification.h" 42 | #import "LFNSObject+Model.h" 43 | #import "LFNSString+URLString.h" 44 | #import "LFNSString+Add.h" 45 | 46 | //UIKit 47 | #import "LFUIAlertController+Blocks.h" 48 | #import "LFUIAlertView+Blocks.h" 49 | #import "LFUIApplication+Add.h" 50 | #import "LFUIBarButtonItem+Image.h" 51 | #import "LFUIBarButtonItem+Add.h" 52 | #import "LFUIBezierPath+Add.h" 53 | #import "LFUIColor+Add.h" 54 | #import "LFUIControl+Add.h" 55 | #import "LFUIDevice+Add.h" 56 | #import "LFUIFont+Add.h" 57 | #import "LFUIGestureRecognizer+Add.h" 58 | #import "LFUIImage+Scale.h" 59 | #import "LFUIImage+Add.h" 60 | #import "LFUINavigationController+Add.h" 61 | #import "LFUIScrollView+Add.h" 62 | #import "LFUITableView+Add.h" 63 | #import "LFUIView+Badge.h" 64 | #import "LFUIView+Add.h" 65 | #import "LFUIViewController+Add.h" 66 | #import "LFCALayer+Add.h" 67 | #import "LFUIView+MBProgressHUD.h" 68 | #import "LFNSMutableArray+Add.h" 69 | #import "LFUIImage+AudioIcon.h" 70 | #import "LFUIButton+EnlargeEdge.h" 71 | #import "LFNSString+Currency.h" 72 | 73 | // Text 74 | //#import "NSAttributedString+LFText.h" 75 | //#import "NSParagraphStyle+LFText.h" 76 | //#import "LFRichTextRunDelegate.h" 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIGestureRecognizer+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIGestureRecognizer+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-10-13. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFUIGestureRecognizer+Add.h" 10 | #import "LFCategoryMacro.h" 11 | #import 12 | 13 | static const int block_key; 14 | 15 | @interface _LFUIGestureRecognizerBlockTarget : NSObject 16 | 17 | @property (nonatomic, copy) void (^block)(id sender); 18 | 19 | - (id)initWithBlock:(void (^)(id sender))block; 20 | - (void)invoke:(id)sender; 21 | 22 | @end 23 | 24 | @implementation _LFUIGestureRecognizerBlockTarget 25 | 26 | - (id)initWithBlock:(void (^)(id sender))block{ 27 | self = [super init]; 28 | if (self) { 29 | self.block = block; 30 | } 31 | return self; 32 | } 33 | 34 | - (void)invoke:(id)sender { 35 | if (self.block) self.block(sender); 36 | } 37 | 38 | 39 | @end 40 | 41 | 42 | 43 | 44 | @implementation UIGestureRecognizer (LFAdditions) 45 | 46 | - (instancetype)initWithActionBlock:(void (^)(id sender))block { 47 | self = [self init]; 48 | [self lf_addActionBlock:block]; 49 | return self; 50 | } 51 | 52 | - (void)lf_addActionBlock:(void (^)(id sender))block { 53 | _LFUIGestureRecognizerBlockTarget *target = [[_LFUIGestureRecognizerBlockTarget alloc] initWithBlock:block]; 54 | [self addTarget:target action:@selector(invoke:)]; 55 | NSMutableArray *targets = [self _lf_allUIGestureRecognizerBlockTargets]; 56 | [targets addObject:target]; 57 | } 58 | 59 | - (void)lf_removeAllActionBlocks{ 60 | NSMutableArray *targets = [self _lf_allUIGestureRecognizerBlockTargets]; 61 | [targets enumerateObjectsUsingBlock:^(id target, NSUInteger idx, BOOL *stop) { 62 | [self removeTarget:target action:@selector(invoke:)]; 63 | }]; 64 | [targets removeAllObjects]; 65 | } 66 | 67 | - (NSMutableArray *)_lf_allUIGestureRecognizerBlockTargets { 68 | NSMutableArray *targets = objc_getAssociatedObject(self, &block_key); 69 | if (!targets) { 70 | targets = [NSMutableArray array]; 71 | objc_setAssociatedObject(self, &block_key, targets, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 72 | } 73 | return targets; 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIApplication+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIApplication+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-4. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /// Returns "Documents" folder in this app's sandbox. 12 | NSString *NSDocumentsPath(void); 13 | 14 | /// Returns "Library" folder in this app's sandbox. 15 | NSString *NSLibraryPath(void); 16 | 17 | /// Returns "Caches" folder in this app's sandbox. 18 | NSString *NSCachesPath(void); 19 | 20 | 21 | /** 22 | Provides extensions for `UIApplication`. 23 | */ 24 | @interface UIApplication (LFAdditions) 25 | 26 | /// "Documents" folder in this app's sandbox. 27 | @property (nonatomic, readonly,getter=lf_documentsURL) NSURL *documentsURL; 28 | 29 | /// "Caches" folder in this app's sandbox. 30 | @property (nonatomic, readonly, getter=lf_cachesURL) NSURL *cachesURL; 31 | 32 | /// "Library" folder in this app's sandbox. 33 | @property (nonatomic, readonly, getter=lf_libraryURL) NSURL *libraryURL; 34 | 35 | /// Application's Bundle Name (show in SpringBoard). 36 | @property (nonatomic, readonly, getter=lf_appBundleName) NSString *appBundleName; 37 | 38 | /// Application's Bundle ID. e.g. "com.live Interactive.MyApp" 39 | @property (nonatomic, readonly, getter=lf_appBundleID) NSString *appBundleID; 40 | 41 | /// Application's Version. e.g. "1.2.0" 42 | @property (nonatomic, readonly, getter=lf_appVersion) NSString *appVersion; 43 | 44 | /// Application's Build number. e.g. "123" 45 | @property (nonatomic, readonly, getter=lf_appBuildVersion) NSString *appBuildVersion; 46 | 47 | /// Current thread real memory used in byte. (-1 when error occurs) 48 | @property (nonatomic, readonly, getter=lf_memoryUsage) int64_t memoryUsage; 49 | 50 | /// Current thread CPU usage, 1.0 means 100%. (-1 when error occurs) 51 | @property (nonatomic, readonly, getter=lf_cpuUsage) float cpuUsage; 52 | 53 | 54 | /// App是否被破解了 55 | /// Whether this app is priated (not from appstore). 56 | @property (nonatomic, readonly, getter=lf_isPirated) BOOL isPirated; 57 | 58 | /// App是否正在被调试 59 | /// Whether this app is being debugged (debugger attached). 60 | @property (nonatomic, readonly, getter=lf_isBeingDebugged) BOOL isBeingDebugged; 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSDate+Format.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+Format.m 3 | // LFCategory 4 | // 5 | // Created by WangZhiWei on 16/5/19. 6 | // Copyright © 2016年 youku. All rights reserved. 7 | // 8 | 9 | #import "LFNSDate+Format.h" 10 | 11 | @implementation NSDate (LFFormatAdditions) 12 | 13 | - (NSString *)lf_stringWithFormat:(NSString *)format { 14 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 15 | [formatter setDateFormat:format]; 16 | [formatter setLocale:[NSLocale currentLocale]]; 17 | return [formatter stringFromDate:self]; 18 | } 19 | 20 | - (NSString *)lf_stringWithFormat:(NSString *)format timeZone:(NSTimeZone *)timeZone locale:(NSLocale *)locale { 21 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 22 | [formatter setDateFormat:format]; 23 | if (timeZone) [formatter setTimeZone:timeZone]; 24 | if (locale) [formatter setLocale:locale]; 25 | return [formatter stringFromDate:self]; 26 | } 27 | 28 | - (NSString *)lf_stringWithISOFormat { 29 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 30 | formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; 31 | formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ssZ"; 32 | return [formatter stringFromDate:self]; 33 | } 34 | 35 | + (NSDate *)lf_dateWithString:(NSString *)dateString format:(NSString *)format { 36 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 37 | [formatter setDateFormat:format]; 38 | return [formatter dateFromString:dateString]; 39 | } 40 | 41 | + (NSDate *)lf_dateWithString:(NSString *)dateString format:(NSString *)format timeZone:(NSTimeZone *)timeZone locale:(NSLocale *)locale { 42 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 43 | [formatter setDateFormat:format]; 44 | if (timeZone) [formatter setTimeZone:timeZone]; 45 | if (locale) [formatter setLocale:locale]; 46 | return [formatter dateFromString:dateString]; 47 | } 48 | 49 | + (NSDate *)lf_dateWithISOFormatString:(NSString *)dateString { 50 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 51 | formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; 52 | formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ssZ"; 53 | return [formatter dateFromString:dateString]; 54 | } 55 | 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSObject+AddForNotification.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+LFAddForNotification.m 3 | // LaiFeng 4 | // 5 | // Created by guoyaoyuan on 16/2/23. 6 | // Copyright © 2016年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFNSObject+AddForNotification.h" 10 | #import "LFWeakProxy.h" 11 | #import 12 | 13 | @implementation NSObject (LFAddForNotification) 14 | 15 | - (NSMutableDictionary *)_lf_observersForNotification { 16 | NSMutableDictionary *targets = objc_getAssociatedObject(self, _cmd); 17 | if (!targets) { 18 | targets = @{}.mutableCopy; 19 | objc_setAssociatedObject(self, _cmd, targets, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 20 | } 21 | return targets; 22 | } 23 | 24 | - (void)lf_addNotifName:(NSString *)notifName block:(void(^)(NSNotification *notif))block { 25 | if (!notifName || !block) return; 26 | NSObject *observer = [[NSNotificationCenter defaultCenter] addObserverForName:notifName object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { 27 | block(note); 28 | }]; 29 | NSMutableArray *obs = [self _lf_observersForNotification][notifName]; 30 | if (!obs) { 31 | obs = [NSMutableArray new]; 32 | [self _lf_observersForNotification][notifName] = obs; 33 | } 34 | [obs addObject:[LFWeakProxy proxyWithTarget:observer]]; 35 | } 36 | 37 | - (void)lf_removeNotifName:(NSString *)notifName { 38 | if (!notifName) return; 39 | NSMutableArray *obs = [self _lf_observersForNotification][notifName]; 40 | for (LFWeakProxy *proxy in obs) { 41 | if (proxy.target) { 42 | [[NSNotificationCenter defaultCenter] removeObserver:proxy.target]; 43 | } 44 | } 45 | [[self _lf_observersForNotification] removeObjectForKey:notifName]; 46 | } 47 | 48 | - (void)lf_removeAllNotif { 49 | [[self _lf_observersForNotification] enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSMutableArray *obs, BOOL *stop) { 50 | for (LFWeakProxy *proxy in obs) { 51 | if (proxy.target) { 52 | [[NSNotificationCenter defaultCenter] removeObserver:proxy.target]; 53 | } 54 | } 55 | }]; 56 | [[self _lf_observersForNotification] removeAllObjects]; 57 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIImage+Scale.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+Addtional.h 3 | // LaiFeng 4 | // 5 | // Created by xinliu on 14-5-29. 6 | // Copyright (c) 2014年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface UIImage (LFScaleAdditions) 13 | // 缩放图片 14 | //scale 适应于位图的缩放系数。如果制定这个值为0.0,那么这个缩放系数就被设置成设备主屏幕的缩放系数 15 | + (UIImage *)lf_scaleImage:(UIImage *)image scaleToSize:(CGSize)size scale:(CGFloat)scale; 16 | 17 | + (UIImage*)lf_clipImage:(UIImage *)originalImage rect:(CGRect)rect; 18 | 19 | //中间拉伸自动宽高 20 | //+ (UIImage*)middleStretchableImageWithKey:(NSString*)key ; 21 | //中间拉伸图片,不支持换肤 22 | + (UIImage *)lf_middleStretchableImageWithOutSupportSkin:(NSString *)key; 23 | 24 | + (UIImage *)lf_createRoundedRectImage:(UIImage*)image size:(CGSize)size cornerRadius:(CGFloat)radius; 25 | 26 | // 缩放图片并且剧中截取 27 | + (UIImage *)lf_middleScaleImage:(UIImage *)image scaleToSize:(CGSize)size; 28 | //宽高取小缩放,取大居中截取 29 | + (UIImage *)lf_suitableScaleImage:(UIImage *)image scaleToSize:(CGSize)size; 30 | //等比缩放到多少倍 31 | + (UIImage *)lf_scaleImage:(UIImage *)image toScale:(float)scaleSize; 32 | //等比例缩放 33 | +(UIImage*)lf_scaleToSize:(UIImage*)image size:(CGSize)size; 34 | // zhengzheng 35 | //等比缩放 36 | + (UIImage *) lf_scaleImageForImage:(UIImage *)image toScale:(float)scaleSize; 37 | - (UIImage *)lf_fixOrientation; 38 | 39 | + (UIImage *)lf_cutIntoImageToSquare:(UIImage *)image; 40 | 41 | //截取部分图像(区分高分屏或者低分屏) 42 | /* ++++++++++++++++++++++++++++++++++++++ 43 | * 44 | * zhengzheng 45 | 46 | @param img 需要被截取的图片 47 | @param scale 倍率(低分屏1.0 高分屏2.0) 48 | @param rect 截取的范围 49 | @return 返回截取后的图片 50 | */ 51 | + (UIImage*)lf_getSubImage:(UIImage *)img scale:(CGFloat)scale rect:(CGRect)rect; 52 | /* ------------------------------------- */ 53 | 54 | // 判断是否超长超宽图(宽高比大于4) 55 | + (BOOL)lf_isLongwidePhoto:(UIImage*)image; 56 | 57 | // 将宽高比大于4的图,截取顶部的宽高 1:2 的部分 58 | + (UIImage*)lf_longwidePhotoToNormal:(UIImage*)image; 59 | 60 | + (UIImage *)lf_compressImageIfNeed:(UIImage *)originImage; 61 | 62 | /** 63 | * @brief 裁剪图片 64 | * @param image 需要裁剪的图片 65 | * @param size 需要裁剪的长度和宽度(两者都是size) 66 | * @returns 裁剪后的图片 67 | */ 68 | + (UIImage *)lf_scaleAndRotateImage:(UIImage *)image size:(NSInteger)size; 69 | 70 | + (CGSize)lf_imageSizeWithData:(NSData *)data; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSDate+Update.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+Update.m 3 | // LFCategory 4 | // 5 | // Created by WangZhiWei on 16/5/19. 6 | // Copyright © 2016年 youku. All rights reserved. 7 | // 8 | 9 | #import "LFNSDate+Update.h" 10 | 11 | @implementation NSDate (LFUpdateAdditions) 12 | 13 | - (NSDate *)lf_dateByAddingYears:(NSInteger)years { 14 | NSCalendar *calendar = [NSCalendar currentCalendar]; 15 | NSDateComponents *components = [[NSDateComponents alloc] init]; 16 | [components setYear:years]; 17 | return [calendar dateByAddingComponents:components toDate:self options:0]; 18 | } 19 | 20 | - (NSDate *)lf_dateByAddingMonths:(NSInteger)months { 21 | NSCalendar *calendar = [NSCalendar currentCalendar]; 22 | NSDateComponents *components = [[NSDateComponents alloc] init]; 23 | [components setMonth:months]; 24 | return [calendar dateByAddingComponents:components toDate:self options:0]; 25 | } 26 | 27 | - (NSDate *)lf_dateByAddingWeeks:(NSInteger)weeks { 28 | NSCalendar *calendar = [NSCalendar currentCalendar]; 29 | NSDateComponents *components = [[NSDateComponents alloc] init]; 30 | [components setWeekOfYear:weeks]; 31 | return [calendar dateByAddingComponents:components toDate:self options:0]; 32 | } 33 | 34 | - (NSDate *)lf_dateByAddingDays:(NSInteger)days { 35 | NSTimeInterval aTimeInterval = [self timeIntervalSinceReferenceDate] + 86400 * days; 36 | NSDate *newDate = [NSDate dateWithTimeIntervalSinceReferenceDate:aTimeInterval]; 37 | return newDate; 38 | } 39 | 40 | - (NSDate *)lf_dateByAddingHours:(NSInteger)hours { 41 | NSTimeInterval aTimeInterval = [self timeIntervalSinceReferenceDate] + 3600 * hours; 42 | NSDate *newDate = [NSDate dateWithTimeIntervalSinceReferenceDate:aTimeInterval]; 43 | return newDate; 44 | } 45 | 46 | - (NSDate *)lf_dateByAddingMinutes:(NSInteger)minutes { 47 | NSTimeInterval aTimeInterval = [self timeIntervalSinceReferenceDate] + 60 * minutes; 48 | NSDate *newDate = [NSDate dateWithTimeIntervalSinceReferenceDate:aTimeInterval]; 49 | return newDate; 50 | } 51 | 52 | - (NSDate *)lf_dateByAddingSeconds:(NSInteger)seconds { 53 | NSTimeInterval aTimeInterval = [self timeIntervalSinceReferenceDate] + seconds; 54 | NSDate *newDate = [NSDate dateWithTimeIntervalSinceReferenceDate:aTimeInterval]; 55 | return newDate; 56 | } 57 | 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIBezierPath+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIBezierPath+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 14/10/30. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFUIBezierPath+Add.h" 10 | #import "LFUIFont+Add.h" 11 | #import 12 | #import "LFCategoryMacro.h" 13 | 14 | 15 | @implementation UIBezierPath (LFAdditions) 16 | 17 | + (UIBezierPath *)lf_bezierPathWithText:(NSString *)text font:(UIFont *)font { 18 | CTFontRef ctFont = font.lf_CTFontRef; 19 | if (!ctFont) return nil; 20 | NSDictionary *attrs = @{ (__bridge id)kCTFontAttributeName:(__bridge id)ctFont }; 21 | NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:text attributes:attrs]; 22 | CFRelease(ctFont); 23 | 24 | CTLineRef line = CTLineCreateWithAttributedString((__bridge CFTypeRef)attrString); 25 | if (!line) return nil; 26 | 27 | CGMutablePathRef cgPath = CGPathCreateMutable(); 28 | CFArrayRef runs = CTLineGetGlyphRuns(line); 29 | for (CFIndex iRun = 0, iRunMax = CFArrayGetCount(runs); iRun < iRunMax; iRun++) { 30 | CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runs, iRun); 31 | CTFontRef runFont = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName); 32 | 33 | for (CFIndex iGlyph = 0, iGlyphMax = CTRunGetGlyphCount(run); iGlyph < iGlyphMax; iGlyph++) { 34 | CFRange glyphRange = CFRangeMake(iGlyph, 1); 35 | CGGlyph glyph; 36 | CGPoint position; 37 | CTRunGetGlyphs(run, glyphRange, &glyph); 38 | CTRunGetPositions(run, glyphRange, &position); 39 | 40 | CGPathRef glyphPath = CTFontCreatePathForGlyph(runFont, glyph, NULL); 41 | if (glyphPath) { 42 | CGAffineTransform transform = CGAffineTransformMakeTranslation(position.x, position.y); 43 | CGPathAddPath(cgPath, &transform, glyphPath); 44 | CGPathRelease(glyphPath); 45 | } 46 | } 47 | } 48 | UIBezierPath *path = [UIBezierPath bezierPathWithCGPath:cgPath]; 49 | CGRect boundingBox = CGPathGetBoundingBox(cgPath); 50 | CFRelease(cgPath); 51 | CFRelease(line); 52 | 53 | [path applyTransform:CGAffineTransformMakeScale(1.0, -1.0)]; 54 | [path applyTransform:CGAffineTransformMakeTranslation(0.0, boundingBox.size.height)]; 55 | 56 | return path; 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIBarButtonItem+Image.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIBarButtonItem+Image.h 3 | // LaiFeng 4 | // 5 | // Created by xinliu on 14-4-25. 6 | // Copyright (c) 2014年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface UIBarButtonItem (LFCustomImageAdditions) 13 | 14 | + (UIBarButtonItem *)lf_rsBarButtonItemWithTitle:(NSString *)title 15 | target:(id)target 16 | action:(SEL)selector; 17 | // 可扩展 18 | + (UIBarButtonItem *)lf_rsBarButtonItemWithTitle:(NSString *)title 19 | image:(UIImage *)image 20 | heightLightImage:(UIImage *)hlImage 21 | disableImage:(UIImage *)disImage 22 | target:(id)target 23 | action:(SEL)selector; 24 | 25 | + (UIBarButtonItem *)lf_rsLeftBarButtonItemWithTitle:(NSString *)title 26 | image:(UIImage *)image 27 | heightLightImage:(UIImage *)hlImage 28 | disableImage:(UIImage *)disImage 29 | target:(id)target 30 | action:(SEL)selector; 31 | 32 | + (UIBarButtonItem *)lf_rsBarButtonItemWithBellButton:(UIButton *)bellButton 33 | image:(UIImage *)image 34 | heightLightImage:(UIImage *)hlImage 35 | disableImage:(UIImage *)disImage 36 | target:(id)target 37 | action:(SEL)selector; 38 | 39 | + (UIButton*)lf_rsCustomBarButtonWithTitle:(NSString*)title 40 | image:(UIImage *)image 41 | heightLightImage:(UIImage *)hlImage 42 | disableImage:(UIImage *)disImage 43 | target:(id)target 44 | action:(SEL)selector; 45 | 46 | - (void)lf_setButtonAttribute:(NSDictionary*)dic; 47 | 48 | @end 49 | 50 | @interface UIToolbar(UIToolbar_Image) 51 | 52 | // 设置底边条背景图片 53 | //- (void)setToolBarWithImageKey:(NSString *)imageKey; 54 | 55 | - (void)lf_setToolBarWithImage:(UIImage *)image; 56 | // 清空底边条的背景图片,使恢复到系统默认状态 57 | - (void)lf_clearToolBarImage; 58 | 59 | 60 | @end 61 | 62 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSDate+Property.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-11. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFNSDate+Property.h" 10 | #import "LFCategoryMacro.h" 11 | 12 | 13 | 14 | @implementation NSDate (LFPropertyAdditions) 15 | 16 | - (NSInteger)lf_year { 17 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitYear fromDate:self] year]; 18 | } 19 | 20 | - (NSInteger)lf_month { 21 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitMonth fromDate:self] month]; 22 | } 23 | 24 | - (NSInteger)lf_day { 25 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitDay fromDate:self] day]; 26 | } 27 | 28 | - (NSInteger)lf_hour { 29 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitHour fromDate:self] hour]; 30 | } 31 | 32 | - (NSInteger)lf_minute { 33 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitMinute fromDate:self] minute]; 34 | } 35 | 36 | - (NSInteger)lf_second { 37 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitSecond fromDate:self] second]; 38 | } 39 | 40 | - (NSInteger)lf_nanosecond { 41 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitSecond fromDate:self] nanosecond]; 42 | } 43 | 44 | - (NSInteger)lf_weekday { 45 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitWeekday fromDate:self] weekday]; 46 | } 47 | 48 | - (NSInteger)lf_weekdayOrdinal { 49 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitWeekdayOrdinal fromDate:self] weekdayOrdinal]; 50 | } 51 | 52 | - (NSInteger)lf_weekOfMonth { 53 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitWeekOfMonth fromDate:self] weekOfMonth]; 54 | } 55 | 56 | - (NSInteger)lf_weekOfYear { 57 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitWeekOfYear fromDate:self] weekOfYear]; 58 | } 59 | 60 | - (NSInteger)lf_yearForWeekOfYear { 61 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitYearForWeekOfYear fromDate:self] yearForWeekOfYear]; 62 | } 63 | 64 | - (NSInteger)quarter { 65 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitQuarter fromDate:self] quarter]; 66 | } 67 | 68 | - (BOOL)lf_isLeapMonth { 69 | return [[[NSCalendar currentCalendar] components:NSCalendarUnitQuarter fromDate:self] isLeapMonth]; 70 | } 71 | 72 | - (BOOL)lf_isLeapYear { 73 | NSUInteger year = self.lf_year; 74 | if ((year % 400 == 0) || (year % 100 == 0) || (year % 4 == 0)) return YES; 75 | return NO; 76 | } 77 | @end 78 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIView+DKAnalyses.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+DKAnalyses.m 3 | // GCDDemo 4 | // 5 | // Created by wangxiaoxiang on 16/3/31. 6 | // Copyright © 2016年 wangxiaoxiang. All rights reserved. 7 | // 8 | 9 | 10 | #if DEBUG 11 | #import "LFUIView+DKAnalyses.h" 12 | #import 13 | 14 | 15 | NSMutableDictionary *g_alloc_count_views_dictionary = nil; 16 | 17 | @implementation UIView (LFDKAnalysesAdditions) 18 | 19 | 20 | +(NSDictionary *)lf_allocAnalysesViewsDictionary 21 | { 22 | NSMutableDictionary *result = [[NSMutableDictionary alloc] init]; 23 | 24 | for(NSString *key in g_alloc_count_views_dictionary.allKeys){ 25 | NSNumber *number = g_alloc_count_views_dictionary[key]; 26 | if(number.integerValue > 0 && key.length >= 3 && ![[key substringWithRange:NSMakeRange(0, 2)] isEqualToString:@"UI"] 27 | && ![[key substringWithRange:NSMakeRange(0, 3)] isEqualToString:@"_UI"] 28 | ){ 29 | [result setObject:g_alloc_count_views_dictionary[key] forKey:key]; 30 | } 31 | } 32 | 33 | return result; 34 | } 35 | 36 | + (void)load 37 | { 38 | [super load]; 39 | static dispatch_once_t onceToken; 40 | dispatch_once(&onceToken, ^{ 41 | g_alloc_count_views_dictionary = [[NSMutableDictionary alloc] init]; 42 | //1 43 | SEL originSEL = NSSelectorFromString(@"dealloc"); 44 | Method origin_dealloc_Method = class_getInstanceMethod([UIView class],originSEL); 45 | Method dk_dealloc_Method = class_getInstanceMethod([UIView class], @selector(dk_dealloc)); 46 | method_exchangeImplementations(dk_dealloc_Method, origin_dealloc_Method); 47 | 48 | //2 49 | Method origin_alloc_Method = class_getInstanceMethod([UIView class], @selector(initWithFrame:)); 50 | Method dk_alloc_Method = class_getInstanceMethod([UIView class], @selector(dk_initWithName:)); 51 | method_exchangeImplementations(dk_alloc_Method, origin_alloc_Method); 52 | }); 53 | } 54 | 55 | - (void)dk_dealloc 56 | { 57 | NSNumber *number = g_alloc_count_views_dictionary[NSStringFromClass([self class])]; 58 | g_alloc_count_views_dictionary[NSStringFromClass([self class])] = @(number.unsignedLongLongValue - 1); 59 | [self dk_dealloc]; 60 | } 61 | 62 | - (instancetype)dk_initWithName:(CGRect)frame 63 | { 64 | NSNumber *number = g_alloc_count_views_dictionary[NSStringFromClass([self class])]; 65 | g_alloc_count_views_dictionary[NSStringFromClass([self class])] = @(number.unsignedLongLongValue + 1); 66 | return [self dk_initWithName:frame]; 67 | } 68 | 69 | 70 | 71 | @end 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSBundle+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSBundle+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-10-20. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provides extensions for `NSBundle` to get resource by @2x or @3x... 13 | 14 | 优先根据屏幕scale来搜索。 15 | 搜索不到时先 16 | */ 17 | @interface NSBundle (LFNSBundleAdditions) 18 | 19 | /** 20 | 在bundle里查找指定文件,并返回完整文件路径。 21 | 这里首先会根据屏幕的scale来搜索资源,例如iPhone5的@2x,如果搜索不到,则从最高分辨率@3x向下搜索。 22 | 23 | @param name The name of a resource file contained in the directory 24 | specified by bundlePath. 25 | 26 | @param ext If extension is an empty string or nil, the extension is 27 | assumed not to exist and the file is the first file encountered that exactly matches name. 28 | 29 | @param bundlePath The path of a top-level bundle directory. This must be a 30 | valid path. For example, to specify the bundle directory for a Mac app, you 31 | might specify the path /Applications/MyApp.app. 32 | 33 | @return The full pathname for the resource file or nil if the file could not be 34 | located. This method also returns nil if the bundle specified by the bundlePath 35 | parameter does not exist or is not a readable directory. 36 | */ 37 | + (NSString *)lf_pathForScaledResource:(NSString *)name ofType:(NSString *)ext inDirectory:(NSString *)bundlePath; 38 | 39 | /** 40 | 在bundle里查找指定文件,并返回完整文件路径。 41 | 这里首先会根据屏幕的scale来搜索资源,例如iPhone5的@2x,如果搜索不到,则从最高分辨率@3x向下搜索。 42 | 43 | @param name The name of the resource file. If name is an empty string or 44 | nil, returns the first file encountered of the supplied type. 45 | 46 | @param ext If extension is an empty string or nil, the extension is 47 | assumed not to exist and the file is the first file encountered that exactly matches name. 48 | 49 | 50 | @return The full pathname for the resource file or nil if the file could not be located. 51 | */ 52 | - (NSString *)lf_pathForScaledResource:(NSString *)name ofType:(NSString *)ext; 53 | 54 | /** 55 | 在bundle里查找指定文件,并返回完整文件路径。 56 | 这里首先会根据屏幕的scale来搜索资源,例如iPhone5的@2x,如果搜索不到,则从最高分辨率@3x向下搜索。 57 | 58 | @param name The name of the resource file. 59 | 60 | @param ext If extension is an empty string or nil, all the files in 61 | subpath and its subdirectories are returned. If an extension is provided the 62 | subdirectories are not searched. 63 | 64 | @param subpath The name of the bundle subdirectory. Can be nil. 65 | 66 | @return An array of full pathnames for the subpath or nil if no files are located. 67 | */ 68 | - (NSString *)lf_pathForScaledResource:(NSString *)name ofType:(NSString *)ext inDirectory:(NSString *)subpath; 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIControl+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIControl+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-5. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provides extensions for `UIControl`. 13 | */ 14 | @interface UIControl (LFAdditions) 15 | 16 | /** 17 | Removes all targets and actions for a particular event (or events) 18 | from an internal dispatch table. 19 | */ 20 | - (void)lf_removeAllTargets; 21 | 22 | /** 23 | Adds or replaces a target and action for a particular event (or events) 24 | to an internal dispatch table. 25 | 26 | @param target The target object—that is, the object to which the 27 | action message is sent. If this is nil, the responder 28 | chain is searched for an object willing to respond to the 29 | action message. 30 | 31 | @param action A selector identifying an action message. It cannot be NULL. 32 | 33 | @param controlEvents A bitmask specifying the control events for which the 34 | action message is sent. 35 | */ 36 | - (void)lf_setTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents; 37 | 38 | /** 39 | Adds a block for a particular event (or events) to an internal dispatch table. 40 | It will cause a strong reference to @a block. 41 | 42 | @param block The block which is invoked then the action message is 43 | sent (cannot be nil). The block is retained. 44 | 45 | @param controlEvents A bitmask specifying the control events for which the 46 | action message is sent. 47 | */ 48 | - (void)lf_addBlockForControlEvents:(UIControlEvents)controlEvents block:(void (^)(id sender))block; 49 | 50 | /** 51 | Adds or replaces a block for a particular event (or events) to an internal 52 | dispatch table. It will cause a strong reference to @a block. 53 | 54 | @param block The block which is invoked then the action message is 55 | sent (cannot be nil). The block is retained. 56 | 57 | @param controlEvents A bitmask specifying the control events for which the 58 | action message is sent. 59 | */ 60 | - (void)lf_setBlockForControlEvents:(UIControlEvents)controlEvents block:(void (^)(id sender))block; 61 | 62 | /** 63 | Removes all blocks for a particular event (or events) from an internal 64 | dispatch table. 65 | 66 | @param controlEvents A bitmask specifying the control events for which the 67 | action message is sent. 68 | */ 69 | - (void)lf_removeAllBlocksForControlEvents:(UIControlEvents)controlEvents; 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIButton+EnlargeEdge.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+EnlargeEdge.m 3 | // iTalk 4 | // 5 | // Created by Si Wen on 15/12/29. 6 | // Copyright © 2015年 Si Wen. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "LFUIButton+EnlargeEdge.h" 12 | 13 | @implementation UIButton (LFEnlargeEdgeAdditions) 14 | static char topNameKey; 15 | static char rightNameKey; 16 | static char bottomNameKey; 17 | static char leftNameKey; 18 | 19 | - (void)lf_setEnlargeEdge:(CGFloat) size { 20 | objc_setAssociatedObject(self, &topNameKey, [NSNumber numberWithFloat:size], OBJC_ASSOCIATION_COPY_NONATOMIC); 21 | objc_setAssociatedObject(self, &rightNameKey, [NSNumber numberWithFloat:size], OBJC_ASSOCIATION_COPY_NONATOMIC); 22 | objc_setAssociatedObject(self, &bottomNameKey, [NSNumber numberWithFloat:size], OBJC_ASSOCIATION_COPY_NONATOMIC); 23 | objc_setAssociatedObject(self, &leftNameKey, [NSNumber numberWithFloat:size], OBJC_ASSOCIATION_COPY_NONATOMIC); 24 | } 25 | 26 | - (void)lf_setEnlargeEdgeWithTop:(CGFloat) top right:(CGFloat) right bottom:(CGFloat) bottom left:(CGFloat) left { 27 | objc_setAssociatedObject(self, &topNameKey, [NSNumber numberWithFloat:top], OBJC_ASSOCIATION_COPY_NONATOMIC); 28 | objc_setAssociatedObject(self, &rightNameKey, [NSNumber numberWithFloat:right], OBJC_ASSOCIATION_COPY_NONATOMIC); 29 | objc_setAssociatedObject(self, &bottomNameKey, [NSNumber numberWithFloat:bottom], OBJC_ASSOCIATION_COPY_NONATOMIC); 30 | objc_setAssociatedObject(self, &leftNameKey, [NSNumber numberWithFloat:left], OBJC_ASSOCIATION_COPY_NONATOMIC); 31 | } 32 | 33 | - (CGRect)enlargedRect { 34 | NSNumber* topEdge = objc_getAssociatedObject(self, &topNameKey); 35 | NSNumber* rightEdge = objc_getAssociatedObject(self, &rightNameKey); 36 | NSNumber* bottomEdge = objc_getAssociatedObject(self, &bottomNameKey); 37 | NSNumber* leftEdge = objc_getAssociatedObject(self, &leftNameKey); 38 | if (topEdge && rightEdge && bottomEdge && leftEdge) { 39 | return CGRectMake(self.bounds.origin.x - leftEdge.floatValue, 40 | self.bounds.origin.y - topEdge.floatValue, 41 | self.bounds.size.width + leftEdge.floatValue + rightEdge.floatValue, 42 | self.bounds.size.height + topEdge.floatValue + bottomEdge.floatValue); 43 | } 44 | else { 45 | return self.bounds; 46 | } 47 | } 48 | - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { 49 | CGRect rect = [self enlargedRect]; 50 | if (CGRectEqualToRect(rect, self.bounds)) { 51 | return [super pointInside:point withEvent:event]; 52 | } 53 | return CGRectContainsPoint(rect, point) ? YES : NO; 54 | } 55 | 56 | @end -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIView+Badge.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+Badge.h 3 | // LaiFeng 4 | // 5 | // Created by limingchen on 15/8/11. 6 | // Copyright (c) 2015年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #pragma mark -- types definition 12 | typedef NS_ENUM(NSUInteger, LFBadgeType) 13 | { 14 | LFBadgeTypeRedDot = 0, /* red dot type */ 15 | LFBadgeTypeNumber, /* badge with number */ 16 | LFBadgeTypeNew /* badge with a fixed text "new" */ 17 | }; 18 | 19 | typedef NS_ENUM(NSUInteger, LFBadgeStyle) 20 | { 21 | LFBadgeStyleNormal = 0, /* badge style rectangle */ 22 | LFBadgeStyleCircle, /* badge style circle */ 23 | }; 24 | 25 | typedef NS_ENUM(NSUInteger, LFBadgeSizeType) { 26 | LFBadgeSizeTypeNormal = 0, /* badge size systom */ 27 | LFBadgeSizeTypeCustom = 1 /* badge size custom */ 28 | }; 29 | 30 | 31 | #pragma mark -- badge apis 32 | 33 | @interface UIView (LFBadgeAdditons) 34 | 35 | @property (nonatomic, strong, setter=setLf_badge:, getter=lf_badge) UILabel *badge; 36 | @property (nonatomic, setter=setLf_badgeOriginX:, getter=lf_badgeOriginX) CGFloat badgeOriginX; 37 | @property (nonatomic, getter=lf_badgeOriginY, setter=setLf_badgeOriginY:) CGFloat badgeOriginY; 38 | @property (nonatomic, getter=lf_showAllNumbers, setter=setLf_showAllNumbers:) BOOL showAllNumbers;//<展示完整的数字 (默认超过100展示99+) 等于0也展示 39 | 40 | 41 | /** 42 | * show badge with red dot style and WBadgeAnimTypeNone by default. 43 | */ 44 | - (void)lf_showRedDotBadge; 45 | - (void)lf_showRedDotBadgeBySizeType:(LFBadgeSizeType)sizeType; 46 | - (void)lf_showRedDotBadgeByStyle:(LFBadgeStyle)style; 47 | - (void)lf_showRedDotBadgeByStyle:(LFBadgeStyle)style sizeType:(LFBadgeSizeType)sizeType; 48 | 49 | /** 50 | * show badge with WBadgeStyleNumber style 51 | */ 52 | - (void)lf_showNewBadge; 53 | - (void)lf_showNewBadgeBySizeType:(LFBadgeSizeType)sizeType; 54 | - (void)lf_showNewBadgeByStyle:(LFBadgeStyle)style; 55 | - (void)lf_showNewBadgeByStyle:(LFBadgeStyle)style sizeType:(LFBadgeSizeType)sizeType; 56 | 57 | /** 58 | * show badge with showNumberBadgeWithValue style 59 | */ 60 | - (void)lf_showNumberBadge:(NSInteger)value; 61 | - (void)lf_showNumberBadge:(NSInteger)value sizeType:(LFBadgeSizeType)sizeType; 62 | - (void)lf_showNumberBadge:(NSInteger)value style:(LFBadgeStyle)style; 63 | - (void)lf_showNumberBadge:(NSInteger)value style:(LFBadgeStyle)style sizeType:(LFBadgeSizeType)sizeType; 64 | 65 | /** 66 | * clear badge 67 | */ 68 | - (void)lf_clearBadge; 69 | 70 | /** 71 | * get current badgeType 72 | */ 73 | - (LFBadgeType)lf_getBadgeType; 74 | 75 | /** 76 | * get bage show 77 | * 78 | */ 79 | 80 | - (BOOL)lf_isShowBage; 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIViewController+DKAnalyses.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+DKAnalyses.m 3 | // GCDDemo 4 | // 5 | // Created by wangxiaoxiang on 16/3/31. 6 | // Copyright © 2016年 wangxiaoxiang. All rights reserved. 7 | // 8 | 9 | 10 | #if DEBUG 11 | #import "LFUIViewController+DKAnalyses.h" 12 | #import 13 | 14 | 15 | NSMutableDictionary *g_alloc_count_dictionary = nil; 16 | 17 | @implementation UIViewController (LFDKAnalysesAdditions) 18 | 19 | 20 | +(NSDictionary *)lf_allocAnalysesDictionary 21 | { 22 | NSMutableDictionary *result = [[NSMutableDictionary alloc] init]; 23 | 24 | for(NSString *key in g_alloc_count_dictionary.allKeys){ 25 | NSNumber *number = g_alloc_count_dictionary[key]; 26 | if(number.integerValue > 0 && key.length >= 3 && ![[key substringWithRange:NSMakeRange(0, 2)] isEqualToString:@"UI"] 27 | && ![[key substringWithRange:NSMakeRange(0, 3)] isEqualToString:@"_UI"] 28 | ){ 29 | [result setObject:g_alloc_count_dictionary[key] forKey:key]; 30 | } 31 | } 32 | 33 | return result; 34 | } 35 | 36 | + (void)load 37 | { 38 | [super load]; 39 | static dispatch_once_t onceToken; 40 | dispatch_once(&onceToken, ^{ 41 | g_alloc_count_dictionary = [[NSMutableDictionary alloc] init]; 42 | //1 43 | SEL originSEL = NSSelectorFromString(@"dealloc"); 44 | Method origin_dealloc_Method = class_getInstanceMethod([UIViewController class],originSEL); 45 | Method dk_dealloc_Method = class_getInstanceMethod([UIViewController class], @selector(dk_dealloc)); 46 | method_exchangeImplementations(dk_dealloc_Method, origin_dealloc_Method); 47 | 48 | //2 49 | Method origin_alloc_Method = class_getInstanceMethod([UIViewController class], @selector(initWithNibName:bundle:)); 50 | Method dk_alloc_Method = class_getInstanceMethod([UIViewController class], @selector(dk_initWithNibName:bundle:)); 51 | method_exchangeImplementations(dk_alloc_Method, origin_alloc_Method); 52 | }); 53 | } 54 | 55 | - (void)dk_dealloc 56 | { 57 | NSNumber *number = g_alloc_count_dictionary[NSStringFromClass([self class])]; 58 | g_alloc_count_dictionary[NSStringFromClass([self class])] = @(number.unsignedLongLongValue - 1); 59 | [self dk_dealloc]; 60 | } 61 | 62 | - (instancetype)dk_initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 63 | { 64 | NSNumber *number = g_alloc_count_dictionary[NSStringFromClass([self class])]; 65 | g_alloc_count_dictionary[NSStringFromClass([self class])] = @(number.unsignedLongLongValue + 1); 66 | return [self dk_initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 67 | } 68 | 69 | 70 | 71 | @end 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSNotificationCenter+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSNotificationCenter+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-8-24. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFNSNotificationCenter+Add.h" 10 | #include 11 | #import "LFCategoryMacro.h" 12 | 13 | 14 | 15 | @implementation NSNotificationCenter (LFAdditions) 16 | 17 | - (void)lf_postNotificationOnMainThread:(NSNotification *)notification { 18 | if (pthread_main_np()) return [self postNotification:notification]; 19 | [self lf_postNotificationOnMainThread:notification waitUntilDone:NO]; 20 | } 21 | 22 | - (void)lf_postNotificationOnMainThread:(NSNotification *)notification waitUntilDone:(BOOL)wait { 23 | if (pthread_main_np()) return [self postNotification:notification]; 24 | [[self class] performSelectorOnMainThread:@selector(_lf_postNotification:) withObject:notification waitUntilDone:wait]; 25 | } 26 | 27 | - (void)lf_postNotificationOnMainThreadWithName:(NSString *)name object:(id)object { 28 | if (pthread_main_np()) return [self postNotificationName:name object:object userInfo:nil]; 29 | [self lf_postNotificationOnMainThreadWithName:name object:object userInfo:nil waitUntilDone:NO]; 30 | } 31 | 32 | - (void)lf_postNotificationOnMainThreadWithName:(NSString *)name object:(id)object userInfo:(NSDictionary *)userInfo { 33 | if (pthread_main_np()) return [self postNotificationName:name object:object userInfo:userInfo]; 34 | [self lf_postNotificationOnMainThreadWithName:name object:object userInfo:userInfo waitUntilDone:NO]; 35 | } 36 | 37 | - (void)lf_postNotificationOnMainThreadWithName:(NSString *)name object:(id)object userInfo:(NSDictionary *)userInfo waitUntilDone:(BOOL)wait { 38 | if (pthread_main_np()) return [self postNotificationName:name object:object userInfo:userInfo]; 39 | NSMutableDictionary *info = [[NSMutableDictionary allocWithZone:nil] initWithCapacity:3]; 40 | if (name) [info setObject:name forKey:@"name"]; 41 | if (object) [info setObject:object forKey:@"object"]; 42 | if (userInfo) [info setObject:userInfo forKey:@"userInfo"]; 43 | [[self class] performSelectorOnMainThread:@selector(_lf_postNotificationName:) withObject:info waitUntilDone:wait]; 44 | } 45 | 46 | + (void)_lf_postNotification:(NSNotification *)notification { 47 | [[self defaultCenter] postNotification:notification]; 48 | } 49 | 50 | + (void)_lf_postNotificationName:(NSDictionary *)info { 51 | NSString *name = [info objectForKey:@"name"]; 52 | id object = [info objectForKey:@"object"]; 53 | NSDictionary *userInfo = [info objectForKey:@"userInfo"]; 54 | 55 | [[self defaultCenter] postNotificationName:name object:object userInfo:userInfo]; 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSMutableArray+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSMutableArray+Add.m 3 | // LFCategory 4 | // 5 | // Created by WangZhiWei on 16/5/19. 6 | // Copyright © 2016年 youku. All rights reserved. 7 | // 8 | 9 | #import "LFNSMutableArray+Add.h" 10 | 11 | @implementation NSMutableArray (LFNSMutableArrayAdditions) 12 | 13 | - (void)lf_removeFirstObject { 14 | if (self.count) { 15 | [self removeObjectAtIndex:0]; 16 | } 17 | } 18 | 19 | #pragma clang diagnostic push 20 | #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation" 21 | - (void)lf_removeLastObject { 22 | if (self.count) { 23 | [self removeObjectAtIndex:self.count - 1]; 24 | } 25 | } 26 | 27 | #pragma clang diagnostic pop 28 | 29 | 30 | - (id)lf_popFirstObject { 31 | id obj = nil; 32 | if (self.count) { 33 | obj = self.firstObject; 34 | [self lf_removeFirstObject]; 35 | } 36 | return obj; 37 | } 38 | 39 | - (id)lf_popLastObject { 40 | id obj = nil; 41 | if (self.count) { 42 | obj = self.lastObject; 43 | [self removeLastObject]; 44 | } 45 | return obj; 46 | } 47 | 48 | - (void)appendObject:(id)anObject { 49 | [self addObject:anObject]; 50 | } 51 | 52 | - (void)lf_prependObject:(id)anObject { 53 | [self insertObject:anObject atIndex:0]; 54 | } 55 | 56 | - (void)appendObjects:(NSArray *)objects { 57 | if (!objects) return; 58 | [self addObjectsFromArray:objects]; 59 | } 60 | 61 | - (void)lf_prependObjects:(NSArray *)objects { 62 | if (!objects) return; 63 | NSUInteger i = 0; 64 | for (id obj in objects) { 65 | [self insertObject:obj atIndex:i++]; 66 | } 67 | } 68 | 69 | - (void)lf_insertObjects:(NSArray *)objects atIndex:(NSUInteger)index { 70 | NSUInteger i = index; 71 | for (id obj in objects) { 72 | [self insertObject:obj atIndex:i++]; 73 | } 74 | } 75 | 76 | - (void)lf_reverse { 77 | NSUInteger count = self.count; 78 | int mid = floor(count / 2.0); 79 | for (NSUInteger i = 0; i < mid; i++) { 80 | [self exchangeObjectAtIndex:i withObjectAtIndex:(count - (i + 1))]; 81 | } 82 | } 83 | 84 | - (void)lf_shuffle { 85 | for (NSUInteger i = self.count; i > 1; i--) { 86 | [self exchangeObjectAtIndex:(i - 1) 87 | withObjectAtIndex:arc4random_uniform((u_int32_t)i)]; 88 | } 89 | } 90 | 91 | 92 | - (void)lf_appendObject:(id)anObject 93 | { 94 | if (anObject && ![anObject isKindOfClass:[NSNull class]]) { 95 | [self addObject:anObject]; 96 | } 97 | } 98 | 99 | - (void)lf_appendObjects:(NSArray *)objects 100 | { 101 | if (objects && [objects isKindOfClass:[NSArray class]]) { 102 | [self addObjectsFromArray:objects]; 103 | } 104 | } 105 | 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /textTools/分类分享/分类说明.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg936\cocoartf1404\cocoasubrtf460 2 | {\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset134 PingFangSC-Regular;} 3 | {\colortbl;\red255\green255\blue255;} 4 | \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh7040\viewkind0 5 | \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0 6 | 7 | \f0\fs24 \cf0 UIView+LXExtension 8 | \f1 \'a3\'ba\ 9 | 1.\'bf\'ec\'cb\'d9\'c9\'e8\'d6\'c3\'bf\'d8\'bc\'feframe\ 10 | 2.\'bf\'ec\'cb\'d9\'b8\'f9\'be\'ddxib\'c9\'fa\'b3\'c9View\ 11 | 3.\'c5\'d0\'b6\'cf\'c1\'bd\'b8\'f6view\'ca\'c7\'b7\'f1\'d6\'d8\'b5\'fe\ 12 | \ 13 | UITextField+LXExtension\'a3\'ba\ 14 | 1.\'c9\'e8\'d6\'c3textField\'b5\'c4\'d5\'bc\'ce\'bb\'ce\'c4\'d7\'d6\'d1\'d5\'c9\'ab\ 15 | \ 16 | UIBarButtonItem+LXExtension\'a3\'ba\ 17 | 1.\'bf\'ec\'cb\'d9\'d7\'d4\'b6\'a8\'d2\'e5\'b5\'bc\'ba\'bd\'c0\'b8\'c9\'cf\'b5\'c4\'b0\'b4\'c5\'a5\ 18 | \ 19 | UIImage+LXExtension\'a3\'ba\ 20 | 1.\'bf\'ec\'cb\'d9\'c9\'fa\'b3\'c9\'d4\'b2\'d0\'ce\'cd\'bc\'c6\'ac\ 21 | 2.\'b8\'f8\'b6\'a8\'d2\'bb\'b8\'f6\'b2\'bb\'d2\'aa\'e4\'d6\'c8\'be\'b5\'c4\'cd\'bc\'c6\'ac\'c3\'fb\'b3\'c6\'a3\'ac\'c9\'fa\'b3\'c9\'d2\'bb\'b8\'f6\'d7\'ee\'d4\'ad\'ca\'bc\'b5\'c4\'cd\'bc\'c6\'ac\ 22 | 3.\'c4\'a3\'ba\'fd\'d0\'a7\'b9\'fb\ 23 | 4.\'b9\'cc\'b6\'a8\'bf\'ed\'b8\'df\ 24 | 5.\'bc\'f4\'c7\'d0\'cd\'bc\'c6\'ac\'c4\'b3\'d2\'bb\'b2\'bf\'b7\'d6\ 25 | 6.\'bd\'ab\'d7\'d4\'c9\'ed\'cc\'ee\'b3\'e4\'b5\'bd\'d6\'b8\'b6\'a8\'b5\'c4size\ 26 | \ 27 | NSString+LXExtension\'a3\'ba\ 28 | 1.\'b8\'f9\'be\'dd\'ce\'c4\'bc\'fe\'c3\'fb\'bc\'c6\'cb\'e3\'ce\'c4\'bc\'fe\'b4\'f3\'d0\'a1\ 29 | 2.\'bf\'ec\'cb\'d9\'c9\'fa\'b3\'c9\'bb\'ba\'b4\'e6/\'ce\'c4\'b5\'b5/\'c1\'d9\'ca\'b1\'c4\'bf\'c2\'bc\'c2\'b7\'be\'b6\ 30 | 3.\'b8\'f9\'be\'dd\'ce\'c4\'d7\'d6\'b7\'b5\'bb\'d8\'ce\'c4\'b1\'be\'d5\'bc\'d3\'c3\'b5\'c4\'b8\'df\'b6\'c8/\'bf\'ed\'b6\'c8\ 31 | \ 32 | NSDate+LXExtension\ 33 | 1.\'c1\'bd\'b8\'f6\'ca\'b1\'bc\'e4\'d6\'ae\'bc\'e4\'b5\'c4\'ca\'b1\'bc\'e4\'bc\'e4\'b8\'f4\ 34 | 2.\'ca\'c7\'b7\'f1\'ce\'aa\'bd\'f1\'cc\'ec\'a3\'ac\'d7\'f2\'cc\'ec\'a3\'ac\'c3\'f7\'cc\'ec\ 35 | 3.\'b5\'b1\'c7\'b0\'ca\'c7\'d6\'dc\'bc\'b8\ 36 | \ 37 | NSDictionary+PropertyCode\ 38 | 1.\'b8\'f9\'be\'dd\'d7\'d6\'b5\'e4\'bf\'ec\'cb\'d9\'c9\'fa\'b3\'c9Property\'ca\'f4\'d0\'d4\ 39 | \'ca\'b9\'d3\'c3\'b3\'a1\'be\'b0\'a3\'ba\'b8\'f9\'be\'dd\'cd\'f8\'c2\'e7\'c7\'eb\'c7\'f3\'b7\'b5\'bb\'d8\'b5\'c4\'d7\'d6\'b5\'e4\'ca\'fd\'be\'dd\'a3\'ac\'d0\'b4\'b6\'d4\'d3\'a6\'b5\'c4\'c4\'a3\'d0\'cd\'a1\'a3\'b5\'b1\'ca\'f4\'d0\'d4\'b6\'e0\'ca\'b1\'a3\'ac\'d3\'c3\'ca\'d6\'d0\'b4\'ba\'dc\'b7\'d1\'b9\'a6\'b7\'f2\'a3\'ac\'bf\'c9\'d3\'c3\'d5\'e2\'b8\'f6\'c0\'e0\'bf\'ec\'cb\'d9\'b4\'f2\'d3\'a1\'b3\'f6\'cb\'f9\'d3\'d0\'b5\'c4\'c4\'a3\'d0\'cd\'ca\'f4\'d0\'d4\'a3\'ac\'d6\'b1\'bd\'d3\'d5\'b3\'cc\'f9\'bc\'b4\'bf\'c9\ 40 | \ 41 | NSObject+JSON\ 42 | \pard\tx866\pardeftab866\pardirnatural\partightenfactor0 43 | \cf0 1.\'d7\'d6\'b5\'e4\'bb\'f2\'b6\'d4\'cf\'f3\'d7\'aa\'b3\'c9JSON\'d7\'d6\'b7\'fb\'b4\'ae\'ca\'fd\'be\'dd\ 44 | \ 45 | } -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIAlertView+Blocks.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertView+Blocks.h 3 | // UIAlertViewBlocks 4 | // 5 | // Created by Ryan Maxwell on 29/08/13. 6 | // 7 | // The MIT License (MIT) 8 | // 9 | // Copyright (c) 2013 Ryan Maxwell 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 12 | // this software and associated documentation files (the "Software"), to deal in 13 | // the Software without restriction, including without limitation the rights to 14 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 15 | // the Software, and to permit persons to whom the Software is furnished to do so, 16 | // subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in all 19 | // copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 23 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 24 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 25 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | #import 30 | 31 | typedef void (^UIAlertViewBlock) (UIAlertView * __nonnull alertView); 32 | typedef void (^UIAlertViewCompletionBlock) (UIAlertView * __nonnull alertView, NSInteger buttonIndex); 33 | 34 | @interface UIAlertView (Blocks) 35 | 36 | + (nonnull instancetype)lf_showWithTitle:(nullable NSString *)title 37 | message:(nullable NSString *)message 38 | style:(UIAlertViewStyle)style 39 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 40 | otherButtonTitles:(nullable NSArray *)otherButtonTitles 41 | tapBlock:(nullable UIAlertViewCompletionBlock)tapBlock; 42 | 43 | + (nonnull instancetype)lf_showWithTitle:(nullable NSString *)title 44 | message:(nullable NSString *)message 45 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 46 | otherButtonTitles:(nullable NSArray *)otherButtonTitles 47 | tapBlock:(nullable UIAlertViewCompletionBlock)tapBlock; 48 | 49 | @property (copy, nonatomic, nullable) UIAlertViewCompletionBlock tapBlock; 50 | @property (copy, nonatomic, nullable) UIAlertViewCompletionBlock willDismissBlock; 51 | @property (copy, nonatomic, nullable) UIAlertViewCompletionBlock didDismissBlock; 52 | 53 | @property (copy, nonatomic, nullable) UIAlertViewBlock willPresentBlock; 54 | @property (copy, nonatomic, nullable) UIAlertViewBlock didPresentBlock; 55 | @property (copy, nonatomic, nullable) UIAlertViewBlock cancelBlock; 56 | 57 | @property (copy, nonatomic, nullable) BOOL(^shouldEnableFirstOtherButtonBlock)(UIAlertView * __nonnull alertView); 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSDictionary+ModelValue.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDictionary+NSDictionaryExt.h 3 | // LaiFeng 4 | // 5 | // Created by xinliu on 14-5-20. 6 | // Copyright (c) 2014年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSDictionary (LFModelValueAdditions) 12 | 13 | /* 14 | 返回指定key的timeInterval值 15 | 没有指定key的值,返回默认值 16 | */ 17 | -(NSTimeInterval)lf_timeIntervalForKey:(NSString *)key withDefault:(NSTimeInterval)defVal; 18 | 19 | /// 源字符串是 timestamp 毫秒数 20 | - (NSDate *)lf_timestampDataForKey:(NSString *)key withDefault:(NSDate *)defVal; 21 | 22 | - (NSString*)lf_queryString; 23 | 24 | 25 | - (id)lf_objectForKey:(NSString*)key class:(Class)aClass; 26 | 27 | 28 | 29 | 30 | #pragma mark - Dictionary Value Getter 31 | ///============================================================================= 32 | /// @name Dictionary Value Getter 33 | ///============================================================================= 34 | 35 | - (BOOL)lf_boolForKey:(NSString *)key withDefault:(BOOL)def; 36 | - (char)lf_charForKey:(NSString *)key withDefault:(char)def; 37 | - (unsigned char)lf_unsignedCharForKey:(NSString *)key withDefault:(unsigned char)def; 38 | - (short)lf_shortForKey:(NSString *)key withDefault:(short)def; 39 | - (unsigned short)lf_unsignedShortForKey:(NSString *)key withDefault:(unsigned short)def; 40 | - (int)lf_intForKey:(NSString *)key withDefault:(int)def; 41 | - (unsigned int)lf_unsignedIntForKey:(NSString *)key withDefault:(unsigned int)def; 42 | - (long)lf_longForKey:(NSString *)key withDefault:(long)def; 43 | - (unsigned long)lf_unsignedLongForKey:(NSString *)key withDefault:(unsigned long)def; 44 | - (long long)lf_longLongForKey:(NSString *)key withDefault:(long long)def; 45 | - (unsigned long long)lf_unsignedLongLongForKey:(NSString *)key withDefault:(unsigned long long)def; 46 | - (float)lf_floatForKey:(NSString *)key withDefault:(float)def; 47 | - (double)lf_doubleForKey:(NSString *)key withDefault:(double)def; 48 | - (NSInteger)lf_integerForKey:(NSString *)key withDefault:(NSInteger)def; 49 | - (NSUInteger)lf_unsignedIntegerForKey:(NSString *)key withDefault:(NSUInteger)def; 50 | - (NSNumber *)lf_numberForKey:(NSString *)key withDefault:(NSNumber *)def; 51 | - (NSString *)lf_stringForKey:(NSString *)key withDefault:(NSString *)def; 52 | 53 | - (BOOL)lf_boolForKey:(NSString *)key; 54 | - (char)lf_charForKey:(NSString *)key; 55 | - (unsigned char)lf_unsignedCharForKey:(NSString *)key; 56 | - (short)lf_shortForKey:(NSString *)key; 57 | - (unsigned short)lf_unsignedShortForKey:(NSString *)key; 58 | - (int)lf_intForKey:(NSString *)key; 59 | - (unsigned int)lf_unsignedIntForKey:(NSString *)key; 60 | - (long)lf_longForKey:(NSString *)key; 61 | - (unsigned long)lf_unsignedLongForKey:(NSString *)key; 62 | - (long long)lf_longLongForKey:(NSString *)key; 63 | - (unsigned long long)lf_unsignedLongLongForKey:(NSString *)key; 64 | - (float)lf_floatForKey:(NSString *)key; 65 | - (double)lf_doubleForKey:(NSString *)key; 66 | - (NSInteger)lf_integerForKey:(NSString *)key; 67 | - (NSUInteger)lf_unsignedIntegerForKey:(NSString *)key; 68 | - (NSNumber *)lf_numberForKey:(NSString *)key; 69 | - (NSString *)lf_stringForKey:(NSString *)key; 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSBundle+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSBundle+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-10-20. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFNSBundle+Add.h" 10 | #import "LFNSString+Add.h" 11 | #import "LFCategoryMacro.h" 12 | 13 | 14 | #define SUPPORT_SCALES @[@3, @2, @1] 15 | 16 | 17 | @implementation NSBundle (LFNSBundleAdditions) 18 | 19 | + (NSArray *)allScales { 20 | static NSMutableArray *scales; 21 | static dispatch_once_t onceToken; 22 | dispatch_once(&onceToken, ^{ 23 | // first search screen's scale, then search from high to low. 24 | scales = SUPPORT_SCALES.mutableCopy; 25 | NSInteger screenScale = [UIScreen mainScreen].scale; 26 | [scales removeObject:@(screenScale)]; 27 | [scales insertObject:@(screenScale) atIndex:0]; 28 | }); 29 | return scales; 30 | } 31 | 32 | + (NSString *)lf_pathForScaledResource:(NSString *)name ofType:(NSString *)ext inDirectory:(NSString *)bundlePath { 33 | if (name.length == 0) return nil; 34 | if ([name hasSuffix:@"/"]) return [self pathForResource:name ofType:ext inDirectory:bundlePath]; 35 | 36 | NSString *path = nil; 37 | 38 | // first search screen's scale, then search from high to low. 39 | NSArray *scales = [NSBundle allScales]; 40 | for (int s = 0; s < scales.count; s++) { 41 | CGFloat scale = ((NSNumber *)scales[s]).floatValue; 42 | NSString *scaledName = ext.length ? [name lf_stringByAppendingNameScale:scale] 43 | : [name lf_stringByAppendingPathScale:scale]; 44 | path = [self pathForResource:scaledName ofType:ext inDirectory:bundlePath]; 45 | if (path) break; 46 | } 47 | 48 | return path; 49 | } 50 | 51 | - (NSString *)lf_pathForScaledResource:(NSString *)name ofType:(NSString *)ext { 52 | if (name.length == 0) return nil; 53 | if ([name hasSuffix:@"/"]) return [self pathForResource:name ofType:ext]; 54 | 55 | NSString *path = nil; 56 | 57 | // first search screen's scale, then search from high to low. 58 | NSArray *scales = [NSBundle allScales]; 59 | for (int s = 0; s < scales.count; s++) { 60 | CGFloat scale = ((NSNumber *)scales[s]).floatValue; 61 | NSString *scaledName = ext.length ? [name lf_stringByAppendingNameScale:scale] 62 | : [name lf_stringByAppendingPathScale:scale]; 63 | path = [self pathForResource:scaledName ofType:ext]; 64 | if (path) break; 65 | } 66 | 67 | return path; 68 | } 69 | 70 | - (NSString *)lf_pathForScaledResource:(NSString *)name ofType:(NSString *)ext inDirectory:(NSString *)subpath { 71 | if (name.length == 0) return nil; 72 | if ([name hasSuffix:@"/"]) return [self pathForResource:name ofType:ext]; 73 | 74 | NSString *path = nil; 75 | 76 | // first search screen's scale, then search from high to low. 77 | NSArray *scales = [NSBundle allScales]; 78 | for (int s = 0; s < scales.count; s++) { 79 | CGFloat scale = ((NSNumber *)scales[s]).floatValue; 80 | NSString *scaledName = ext.length ? [name lf_stringByAppendingNameScale:scale] 81 | : [name lf_stringByAppendingPathScale:scale]; 82 | path = [self pathForResource:scaledName ofType:ext inDirectory:subpath]; 83 | if (path) break; 84 | } 85 | 86 | return path; 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUITableView+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // UITableView+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-5-12. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFUITableView+Add.h" 10 | #import "LFCategoryMacro.h" 11 | 12 | 13 | @implementation UITableView (LFAdditions) 14 | 15 | - (void)lf_updateWithBlock:(void (^)(UITableView *tableView))block { 16 | [self beginUpdates]; 17 | block(self); 18 | [self endUpdates]; 19 | } 20 | 21 | - (void)lf_scrollToRow:(NSUInteger)row inSection:(NSUInteger)section atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated { 22 | NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section]; 23 | [self scrollToRowAtIndexPath:indexPath atScrollPosition:scrollPosition animated:animated]; 24 | } 25 | 26 | - (void)lf_insertRowAtIndexPath:(NSIndexPath *)indexPath withRowAnimation:(UITableViewRowAnimation)animation { 27 | [self insertRowsAtIndexPaths:@[indexPath] withRowAnimation:animation]; 28 | } 29 | 30 | - (void)lf_insertRow:(NSUInteger)row inSection:(NSUInteger)section withRowAnimation:(UITableViewRowAnimation)animation { 31 | NSIndexPath *toInsert = [NSIndexPath indexPathForRow:row inSection:section]; 32 | [self lf_insertRowAtIndexPath:toInsert withRowAnimation:animation]; 33 | } 34 | 35 | - (void)lf_reloadRowAtIndexPath:(NSIndexPath *)indexPath withRowAnimation:(UITableViewRowAnimation)animation { 36 | [self reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:animation]; 37 | } 38 | 39 | - (void)lf_reloadRow:(NSUInteger)row inSection:(NSUInteger)section withRowAnimation:(UITableViewRowAnimation)animation { 40 | NSIndexPath *toReload = [NSIndexPath indexPathForRow:row inSection:section]; 41 | [self lf_reloadRowAtIndexPath:toReload withRowAnimation:animation]; 42 | } 43 | 44 | - (void)lf_deleteRowAtIndexPath:(NSIndexPath *)indexPath withRowAnimation:(UITableViewRowAnimation)animation { 45 | [self deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:animation]; 46 | } 47 | 48 | - (void)lf_deleteRow:(NSUInteger)row inSection:(NSUInteger)section withRowAnimation:(UITableViewRowAnimation)animation { 49 | NSIndexPath *toDelete = [NSIndexPath indexPathForRow:row inSection:section]; 50 | [self lf_deleteRowAtIndexPath:toDelete withRowAnimation:animation]; 51 | } 52 | 53 | - (void)lf_insertSection:(NSUInteger)section withRowAnimation:(UITableViewRowAnimation)animation { 54 | NSIndexSet *sections = [NSIndexSet indexSetWithIndex:section]; 55 | [self insertSections:sections withRowAnimation:animation]; 56 | } 57 | 58 | - (void)lf_deleteSection:(NSUInteger)section withRowAnimation:(UITableViewRowAnimation)animation { 59 | NSIndexSet *sections = [NSIndexSet indexSetWithIndex:section]; 60 | [self deleteSections:sections withRowAnimation:animation]; 61 | } 62 | 63 | - (void)lf_reloadSection:(NSUInteger)section withRowAnimation:(UITableViewRowAnimation)animation { 64 | NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:section]; 65 | [self reloadSections:indexSet withRowAnimation:animation]; 66 | } 67 | 68 | - (void)lf_clearSelectedRowsAnimated:(BOOL)animated { 69 | NSArray *indexs = [self indexPathsForSelectedRows]; 70 | [indexs enumerateObjectsUsingBlock:^(NSIndexPath* path, NSUInteger idx, BOOL *stop) { 71 | [self deselectRowAtIndexPath:path animated:animated]; 72 | }]; 73 | } 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSObject+AddForKVO.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+LFAddForKVO.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-10-15. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFNSObject+AddForKVO.h" 10 | #import "LFCategoryMacro.h" 11 | #import 12 | #import 13 | 14 | static const int block_key; 15 | 16 | @interface _LFNSObjectKVOBlockTarget : NSObject 17 | 18 | @property (nonatomic, copy) void (^block)(__weak id obj, id oldVal, id newVal); 19 | 20 | - (id)initWithBlock:(void (^)(__weak id obj, id oldVal, id newVal))block; 21 | 22 | @end 23 | 24 | @implementation _LFNSObjectKVOBlockTarget 25 | 26 | - (id)initWithBlock:(void (^)(__weak id obj, id oldVal, id newVal))block { 27 | self = [super init]; 28 | if (self) { 29 | self.block = block; 30 | } 31 | return self; 32 | } 33 | 34 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 35 | if (!self.block) return; 36 | 37 | BOOL isPrior = [[change objectForKey:NSKeyValueChangeNotificationIsPriorKey] boolValue]; 38 | if (isPrior) return; 39 | 40 | NSKeyValueChange changeKind = [[change objectForKey:NSKeyValueChangeKindKey] integerValue]; 41 | if (changeKind != NSKeyValueChangeSetting) return; 42 | 43 | id oldVal = [change objectForKey:NSKeyValueChangeOldKey]; 44 | if (oldVal == [NSNull null]) oldVal = nil; 45 | 46 | id newVal = [change objectForKey:NSKeyValueChangeNewKey]; 47 | if (newVal == [NSNull null]) newVal = nil; 48 | 49 | self.block(object, oldVal, newVal); 50 | } 51 | 52 | @end 53 | 54 | 55 | 56 | @implementation NSObject (LFAddForKVO) 57 | 58 | - (void)lf_addObserverBlockForKeyPath:(NSString *)keyPath block:(void (^)(__weak id obj, id oldVal, id newVal))block { 59 | if (!keyPath || !block) return; 60 | _LFNSObjectKVOBlockTarget *target = [[_LFNSObjectKVOBlockTarget alloc] initWithBlock:block]; 61 | NSMutableDictionary *dic = [self _lf_allNSObjectObserverBlocks]; 62 | NSMutableArray *arr = dic[keyPath]; 63 | if (!arr) { 64 | arr = @[].mutableCopy; 65 | dic[keyPath] = arr; 66 | } 67 | [arr addObject:target]; 68 | [self addObserver:target forKeyPath:keyPath options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL]; 69 | } 70 | 71 | - (void)lf_removeObserverBlocksForKeyPath:(NSString *)keyPath { 72 | if (!keyPath) return; 73 | NSMutableDictionary *dic = [self _lf_allNSObjectObserverBlocks]; 74 | NSMutableArray *arr = dic[keyPath]; 75 | [arr enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) { 76 | [self removeObserver:obj forKeyPath:keyPath]; 77 | }]; 78 | } 79 | 80 | - (void)lf_removeObserverBlocks { 81 | NSMutableDictionary *dic = [self _lf_allNSObjectObserverBlocks]; 82 | [dic enumerateKeysAndObjectsUsingBlock: ^(NSString *key, NSArray *arr, BOOL *stop) { 83 | [arr enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) { 84 | [self removeObserver:obj forKeyPath:key]; 85 | }]; 86 | }]; 87 | } 88 | 89 | - (NSMutableDictionary *)_lf_allNSObjectObserverBlocks { 90 | NSMutableDictionary *targets = objc_getAssociatedObject(self, &block_key); 91 | if (!targets) { 92 | targets = @{}.mutableCopy; 93 | objc_setAssociatedObject(self, &block_key, targets, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 94 | } 95 | return targets; 96 | } 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSNotificationCenter+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSNotificationCenter+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-8-24. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provide some method for `NSNotificationCenter` 13 | to post notification in different thread. 14 | */ 15 | @interface NSNotificationCenter (LFAdditions) 16 | 17 | /** 18 | Posts a given notification to the receiver on main thread. 19 | If current thread is main thread, the notification is posted synchronized; 20 | otherwise, is posted asynchronized. 21 | 22 | @param notification The notification to post. 23 | An exception is raised if notification is nil. 24 | */ 25 | - (void)lf_postNotificationOnMainThread:(NSNotification *)notification; 26 | 27 | /** 28 | Posts a given notification to the receiver on main thread. 29 | 30 | @param notification The notification to post. 31 | An exception is raised if notification is nil. 32 | 33 | @param wait A Boolean that specifies whether the current thread blocks 34 | until after the specified notification is posted on the 35 | receiver on the main thread. Specify YES to block this 36 | thread; otherwise, specify NO to have this method return 37 | immediately. 38 | */ 39 | - (void)lf_postNotificationOnMainThread:(NSNotification *)notification 40 | waitUntilDone:(BOOL)wait; 41 | 42 | /** 43 | Creates a notification with a given name and sender and posts it to the 44 | receiver on main thread. If current thread is main thread, the notification 45 | is posted synchronized; otherwise, is posted asynchronized. 46 | 47 | @param name The name of the notification. 48 | 49 | @param object The object posting the notification. 50 | */ 51 | - (void)lf_postNotificationOnMainThreadWithName:(NSString *)name 52 | object:(id)object; 53 | 54 | /** 55 | Creates a notification with a given name and sender and posts it to the 56 | receiver on main thread. If current thread is main thread, the notification 57 | is posted synchronized; otherwise, is posted asynchronized. 58 | 59 | @param name The name of the notification. 60 | 61 | @param object The object posting the notification. 62 | 63 | @param userInfo Information about the the notification. May be nil. 64 | */ 65 | - (void)lf_postNotificationOnMainThreadWithName:(NSString *)name 66 | object:(id)object 67 | userInfo:(NSDictionary *)userInfo; 68 | 69 | /** 70 | Creates a notification with a given name and sender and posts it to the 71 | receiver on main thread. 72 | 73 | @param name The name of the notification. 74 | 75 | @param object The object posting the notification. 76 | 77 | @param userInfo Information about the the notification. May be nil. 78 | 79 | @param wait A Boolean that specifies whether the current thread blocks 80 | until after the specified notification is posted on the 81 | receiver on the main thread. Specify YES to block this 82 | thread; otherwise, specify NO to have this method return 83 | immediately. 84 | */ 85 | - (void)lf_postNotificationOnMainThreadWithName:(NSString *)name 86 | object:(id)object 87 | userInfo:(NSDictionary *)userInfo 88 | waitUntilDone:(BOOL)wait; 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIControl+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIControl+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-5. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFUIControl+Add.h" 10 | #import "LFCategoryMacro.h" 11 | #import 12 | 13 | 14 | static const int block_key; 15 | 16 | @interface _LFUIControlBlockTarget : NSObject 17 | 18 | @property (nonatomic, copy) void (^block)(id sender); 19 | @property (nonatomic, assign) UIControlEvents events; 20 | 21 | - (id)initWithBlock:(void (^)(id sender))block events:(UIControlEvents)events; 22 | - (void)invoke:(id)sender; 23 | 24 | @end 25 | 26 | @implementation _LFUIControlBlockTarget 27 | 28 | - (id)initWithBlock:(void (^)(id sender))block events:(UIControlEvents)events { 29 | self = [super init]; 30 | if (self) { 31 | self.block = block; 32 | self.events = events; 33 | } 34 | return self; 35 | } 36 | 37 | - (void)invoke:(id)sender { 38 | if (self.block) self.block(sender); 39 | } 40 | 41 | @end 42 | 43 | 44 | 45 | @implementation UIControl (LFAdditions) 46 | 47 | - (void)lf_removeAllTargets { 48 | [[self allTargets] enumerateObjectsUsingBlock: ^(id object, BOOL *stop) { 49 | [self removeTarget:object 50 | action:NULL 51 | forControlEvents:UIControlEventAllEvents]; 52 | }]; 53 | } 54 | 55 | - (void)lf_setTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents { 56 | NSSet *targets = [self allTargets]; 57 | for (id currentTarget in targets) { 58 | NSArray *actions = [self actionsForTarget:currentTarget forControlEvent:controlEvents]; 59 | for (NSString *currentAction in actions) { 60 | [self removeTarget:currentTarget action:NSSelectorFromString(currentAction) 61 | forControlEvents:controlEvents]; 62 | } 63 | } 64 | [self addTarget:target action:action forControlEvents:controlEvents]; 65 | } 66 | 67 | - (void)lf_addBlockForControlEvents:(UIControlEvents)controlEvents 68 | block:(void (^)(id sender))block { 69 | _LFUIControlBlockTarget *target = [[_LFUIControlBlockTarget alloc] 70 | initWithBlock:block events:controlEvents]; 71 | [self addTarget:target action:@selector(invoke:) forControlEvents:controlEvents]; 72 | NSMutableArray *targets = [self _lf_allUIControlBlockTargets]; 73 | [targets addObject:target]; 74 | } 75 | 76 | - (void)lf_setBlockForControlEvents:(UIControlEvents)controlEvents 77 | block:(void (^)(id sender))block { 78 | [self lf_removeAllBlocksForControlEvents:controlEvents]; 79 | [self lf_addBlockForControlEvents:controlEvents block:block]; 80 | } 81 | 82 | - (void)lf_removeAllBlocksForControlEvents:(UIControlEvents)controlEvents { 83 | NSMutableArray *targets = [self _lf_allUIControlBlockTargets]; 84 | NSMutableArray *removes = [NSMutableArray array]; 85 | [targets enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) { 86 | _LFUIControlBlockTarget *target = (_LFUIControlBlockTarget *)obj; 87 | if (target.events == controlEvents) { 88 | [removes addObject:target]; 89 | [self removeTarget:target 90 | action:@selector(invoke:) 91 | forControlEvents:controlEvents]; 92 | } 93 | }]; 94 | [targets removeObjectsInArray:removes]; 95 | } 96 | 97 | - (NSMutableArray *)_lf_allUIControlBlockTargets { 98 | NSMutableArray *targets = objc_getAssociatedObject(self, &block_key); 99 | if (!targets) { 100 | targets = [NSMutableArray array]; 101 | objc_setAssociatedObject(self, &block_key, targets, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 102 | } 103 | return targets; 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /textTools/分类分享/NSString+LXExtension/NSString+LXExtension.m: -------------------------------------------------------------------------------- 1 | 2 | #import "NSString+LXExtension.h" 3 | #import 4 | #import 5 | 6 | /*CC_MD5_DIGEST_LENGTH*/ 7 | 8 | #define MD5_LENGTH 32 9 | @implementation NSString (LXExtension) 10 | 11 | + (NSString*)md5HexDigest:(NSString*)input { 12 | const char* str = [input UTF8String]; 13 | unsigned char result[CC_MD5_DIGEST_LENGTH]; 14 | CC_MD5(str, strlen(str), result); 15 | 16 | NSMutableString *ret = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH*2]; 17 | for(int i = 0; i= M_PI_2*3) {//四区间 74 | calAngle = M_PI*2 - tempAngle; 75 | flag = 0; 76 | }else if(tempAngle >= M_PI)//三区间 77 | { 78 | calAngle = tempAngle - M_PI ; 79 | flag= 1; 80 | }else if(tempAngle >= M_PI_2)//二区间 81 | { 82 | calAngle = M_PI - tempAngle; 83 | flag =2; 84 | }else //一区间 85 | { 86 | calAngle = tempAngle; 87 | flag = 3; 88 | } 89 | 90 | CGFloat height = sin(calAngle)*radius; 91 | CGFloat width = cos(calAngle)*radius; 92 | if (calAngle==0) { 93 | height=0; 94 | width = radius; 95 | }else if (calAngle==M_PI_2) 96 | { 97 | height=radius; 98 | width =0; 99 | } 100 | 101 | 102 | if (i==0) { 103 | CGContextMoveToPoint(ctx, centerX+width, height+centerY); 104 | }else 105 | { 106 | switch (flag) { 107 | case 0://4 108 | CGContextAddLineToPoint(ctx, centerX+width,centerY-height); 109 | break; 110 | case 1://3 111 | CGContextAddLineToPoint(ctx, centerX-width,centerY-height); 112 | break; 113 | case 2://2 114 | CGContextAddLineToPoint(ctx, centerX-width,centerY+height); 115 | break; 116 | case 3://1 117 | CGContextAddLineToPoint(ctx, centerX+width,centerY+height); 118 | break; 119 | } 120 | } 121 | 122 | tempAngle = tempAngle + unitAngle*offset; 123 | 124 | } 125 | 126 | 127 | // CGContextStrokePath(ctx); 128 | 129 | CGContextFillPath(ctx); 130 | 131 | } 132 | 133 | @end 134 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIAlertController+Blocks.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertController+Blocks.h 3 | // UIAlertControllerBlocks 4 | // 5 | // Created by Ryan Maxwell on 11/09/14. 6 | // 7 | // The MIT License (MIT) 8 | // 9 | // Copyright (c) 2014 Ryan Maxwell 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 12 | // this software and associated documentation files (the "Software"), to deal in 13 | // the Software without restriction, including without limitation the rights to 14 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 15 | // the Software, and to permit persons to whom the Software is furnished to do so, 16 | // subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in all 19 | // copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 23 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 24 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 25 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | #import 30 | 31 | typedef void (^UIAlertControllerPopoverPresentationControllerBlock) (UIPopoverPresentationController * __nonnull popover); 32 | typedef void (^UIAlertControllerCompletionBlock) (UIAlertController * __nonnull controller, UIAlertAction * __nonnull action, NSInteger buttonIndex); 33 | 34 | @interface UIAlertController (Blocks) 35 | 36 | + (nonnull instancetype)lf_showInViewController:(nonnull UIViewController *)viewController 37 | withTitle:(nullable NSString *)title 38 | message:(nullable NSString *)message 39 | preferredStyle:(UIAlertControllerStyle)preferredStyle 40 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 41 | destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle 42 | otherButtonTitles:(nullable NSArray *)otherButtonTitles 43 | popoverPresentationControllerBlock:(nullable UIAlertControllerPopoverPresentationControllerBlock)popoverPresentationControllerBlock 44 | tapBlock:(nullable UIAlertControllerCompletionBlock)tapBlock; 45 | 46 | + (nonnull instancetype)lf_showAlertInViewController:(nonnull UIViewController *)viewController 47 | withTitle:(nullable NSString *)title 48 | message:(nullable NSString *)message 49 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 50 | destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle 51 | otherButtonTitles:(nullable NSArray *)otherButtonTitles 52 | tapBlock:(nullable UIAlertControllerCompletionBlock)tapBlock; 53 | 54 | + (nonnull instancetype)lf_showActionSheetInViewController:(nonnull UIViewController *)viewController 55 | withTitle:(nullable NSString *)title 56 | message:(nullable NSString *)message 57 | cancelButtonTitle:(nullable NSString *)cancelButtonTitle 58 | destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle 59 | otherButtonTitles:(nullable NSArray *)otherButtonTitles 60 | popoverPresentationControllerBlock:(nullable UIAlertControllerPopoverPresentationControllerBlock)popoverPresentationControllerBlock 61 | tapBlock:(nullable UIAlertControllerCompletionBlock)tapBlock; 62 | 63 | @property (readonly, nonatomic) BOOL lf_visible; 64 | @property (readonly, nonatomic) NSInteger lf_cancelButtonIndex; 65 | @property (readonly, nonatomic) NSInteger lf_firstOtherButtonIndex; 66 | @property (readonly, nonatomic) NSInteger lf_destructiveButtonIndex; 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFCALayer+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // CALayer+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-5-10. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | /** 13 | Provides extensions for `CALayer`. 14 | */ 15 | @interface CALayer (LFAdditions) 16 | 17 | /** 18 | Take snapshot without transform, image's size equals to bounds. 19 | */ 20 | - (UIImage *)lf_snapshotImage; 21 | 22 | /** 23 | Take snapshot without transform, PDF's page size equals to bounds. 24 | */ 25 | - (NSData *)lf_snapshotPDF; 26 | 27 | /** 28 | Shortcut to set the layer's shadow 29 | 30 | @param color Shadow Color 31 | @param offset Shadow offset 32 | @param radius Shadow radius 33 | */ 34 | - (void)lf_setLayerShadow:(UIColor*)color offset:(CGSize)offset radius:(CGFloat)radius; 35 | 36 | /** 37 | Remove all sublayers. 38 | */ 39 | - (void)lf_removeAllSublayers; 40 | 41 | @property (nonatomic, setter=setLf_left:, getter=lf_left) CGFloat left; ///< Shortcut for frame.origin.x. 42 | @property (nonatomic, setter=setLf_top:, getter=lf_top) CGFloat top; ///< Shortcut for frame.origin.y 43 | @property (nonatomic, setter=setLf_right:, getter=lf_right) CGFloat right; ///< Shortcut for frame.origin.x + frame.size.width 44 | @property (nonatomic, setter=setLf_bottom:, getter=lf_bottom) CGFloat bottom; ///< Shortcut for frame.origin.y + frame.size.height 45 | @property (nonatomic, setter=setLf_width:, getter=lf_width) CGFloat width; ///< Shortcut for frame.size.width. 46 | @property (nonatomic, setter=setLf_height:, getter=lf_height) CGFloat height; ///< Shortcut for frame.size.height. 47 | @property (nonatomic, setter=setLf_center:, getter=lf_center) CGPoint center; ///< Shortcut for center (Add) 48 | @property (nonatomic, setter=setLf_centerX:, getter=lf_centerX) CGFloat centerX; ///< Shortcut for center.x 49 | @property (nonatomic, setter=setLf_centerY:, getter=lf_centerY) CGFloat centerY; ///< Shortcut for center.y 50 | @property (nonatomic, setter=setLf_origin:, getter=lf_origin) CGPoint origin; ///< Shortcut for frame.origin. 51 | @property (nonatomic, getter=frameSize, setter=setFrameSize:) CGSize size; ///< Shortcut for frame.size. 52 | 53 | 54 | @property (nonatomic, setter=setLf_transformRotation:, getter=lf_transformRotation) CGFloat transformRotation; ///< key path "tranform.rotation" 55 | @property (nonatomic, setter=setLf_transformRotationX:, getter=lf_transformRotationX) CGFloat transformRotationX; ///< key path "tranform.rotation.x" 56 | @property (nonatomic, setter=setLf_transformRotationY:, getter=lf_transformRotationY) CGFloat transformRotationY; ///< key path "tranform.rotation.y" 57 | @property (nonatomic, setter=setLf_transformRotationZ:, getter=lf_transformRotationZ) CGFloat transformRotationZ; ///< key path "tranform.rotation.z" 58 | @property (nonatomic, setter=setLf_transformScale:, getter=lf_transformScale) CGFloat transformScale; ///< key path "tranform.scale" 59 | @property (nonatomic, setter=setLf_transformScaleX:, getter=lf_transformScaleX) CGFloat transformScaleX; ///< key path "tranform.scale.x" 60 | @property (nonatomic, setter=setLf_transformScaleY:, getter=lf_transformScaleY) CGFloat transformScaleY; ///< key path "tranform.scale.y" 61 | @property (nonatomic, setter=setLf_transformScaleZ:, getter=lf_transformScaleZ) CGFloat transformScaleZ; ///< key path "tranform.scale.z" 62 | @property (nonatomic, setter=setLf_transformTranslationX:, getter=lf_transformTranslationX) CGFloat transformTranslationX; ///< key path "tranform.translation.x" 63 | @property (nonatomic, setter=setLf_transformTranslationY:, getter=lf_transformTranslationY) CGFloat transformTranslationY; ///< key path "tranform.translation.y" 64 | @property (nonatomic, setter=setLf_transformTranslationZ:, getter=lf_transformTranslationZ) CGFloat transformTranslationZ; ///< key path "tranform.translation.z" 65 | 66 | /** 67 | 做3D效果时,可以很方便用这个调整 68 | Shortcut for transform.m34, -1/1000 is a good value. 69 | It should be set before other transform shortcut. 70 | */ 71 | @property (nonatomic, assign) CGFloat lf_transformDepth; 72 | 73 | 74 | /** 75 | Add a fade animation to layer's contents when the contents is changed. 76 | 77 | @param duration Animation duration 78 | @param curve Animation curve. 79 | */ 80 | - (void)lf_addFadeAnimationWithDuration:(NSTimeInterval)duration curve:(UIViewAnimationCurve)curve; 81 | 82 | /** 83 | Cancel fade animation which is added with "-addFadeAnimationWithDuration:curve:". 84 | */ 85 | - (void)lf_removePreviousFadeAnimation; 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIFont+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIFont+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 14-5-11. 6 | // Copyright (c) 2014 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | /** 14 | Provides extensions for `UIFont`. 15 | */ 16 | @interface UIFont (LFAdditions) 17 | 18 | #pragma mark - Font Traits 19 | ///============================================================================= 20 | /// @name Font Traits 21 | ///============================================================================= 22 | 23 | @property (nonatomic, readonly) BOOL lf_isBold NS_AVAILABLE_IOS(7_0); ///< Whether the font is bold. 24 | @property (nonatomic, readonly) BOOL lf_isItalic NS_AVAILABLE_IOS(7_0); ///< Whether the font is italic. 25 | @property (nonatomic, readonly) BOOL lf_isMonoSpace NS_AVAILABLE_IOS(7_0); ///< Whether the font is mono space. 26 | @property (nonatomic, readonly) BOOL lf_isColorGlyphs NS_AVAILABLE_IOS(7_0); ///< Whether the font is color glyphs (such as Emoji). 27 | @property (nonatomic, readonly) CGFloat lf_fontWeight NS_AVAILABLE_IOS(7_0); ///< Font weight from -1.0 to 1.0. Regular weight is 0.0. 28 | 29 | /** 30 | Create a bold font from receiver. 31 | @return A bold font, or nil if failed. 32 | */ 33 | - (UIFont *)lf_fontWithBold NS_AVAILABLE_IOS(7_0); 34 | 35 | /** 36 | Create a italic font from receiver. 37 | @return A italic font, or nil if failed. 38 | */ 39 | - (UIFont *)lf_fontWithItalic NS_AVAILABLE_IOS(7_0); 40 | 41 | /** 42 | Create a bold and italic font from receiver. 43 | @return A bold and italic font, or nil if failed. 44 | */ 45 | - (UIFont *)lf_fontWithBoldItalic NS_AVAILABLE_IOS(7_0); 46 | 47 | /** 48 | Create a normal (no bold/italic/...) font from receiver. 49 | @return A normal font, or nil if failed. 50 | */ 51 | - (UIFont *)lf_fontWithNormal NS_AVAILABLE_IOS(7_0); 52 | 53 | #pragma mark - Create font 54 | ///============================================================================= 55 | /// @name Create font 56 | ///============================================================================= 57 | 58 | /** 59 | Creates and returns a font object for the specified CTFontRef. 60 | 61 | @param CTFont CoreText font. 62 | */ 63 | + (UIFont *)lf_fontWithCTFont:(CTFontRef)CTFont; 64 | 65 | /** 66 | Creates and returns a font object for the specified CGFontRef and size. 67 | 68 | @param CGFont CoreGraphic font. 69 | @param size Font size. 70 | */ 71 | + (UIFont *)lf_fontWithCGFont:(CGFontRef)CGFont size:(CGFloat)size; 72 | 73 | /** 74 | Creates and returns the CTFontRef object. (need call CFRelease() after used) 75 | */ 76 | - (CTFontRef)lf_CTFontRef CF_RETURNS_RETAINED; 77 | 78 | /** 79 | Creates and returns the CGFontRef object. (need call CFRelease() after used) 80 | */ 81 | - (CGFontRef)lf_CGFontRef CF_RETURNS_RETAINED; 82 | 83 | 84 | #pragma mark - Load and unload font 85 | ///============================================================================= 86 | /// @name Load and unload font 87 | ///============================================================================= 88 | 89 | /** 90 | Load the font from file path. Support format:TTF,OTF. 91 | If return YES, font can be load use it PostScript Name: [UIFont fontWithName:...] 92 | 93 | @param path font file's full path 94 | */ 95 | + (BOOL)lf_loadFontFromPath:(NSString *)path; 96 | 97 | /** 98 | Unload font from file path. 99 | 100 | @param path font file's full path 101 | */ 102 | + (void)lf_unloadFontFromPath:(NSString *)path; 103 | 104 | /** 105 | Load the font from data. Support format:TTF,OTF. 106 | 107 | @param data Font data. 108 | 109 | @return UIFont object if load succeed, otherwise nil. 110 | */ 111 | + (UIFont *)lf_loadFontFromData:(NSData *)data; 112 | 113 | /** 114 | Unload font which is loaded by loadFontFromData: function. 115 | 116 | @param font the font loaded by loadFontFromData: function 117 | 118 | @return YES if succeed, otherwise NO. 119 | */ 120 | + (BOOL)lf_unloadFontFromData:(UIFont *)font; 121 | 122 | 123 | #pragma mark - Dump font data 124 | ///============================================================================= 125 | /// @name Dump font data 126 | ///============================================================================= 127 | 128 | /** 129 | Serialize and return the font data. 130 | 131 | @param font The font. 132 | 133 | @return data in TTF, or nil if an error occurs. 134 | */ 135 | + (NSData *)lf_dataFromFont:(UIFont *)font; 136 | 137 | /** 138 | Serialize and return the font data. 139 | 140 | @param cgFont The font. 141 | 142 | @return data in TTF, or nil if an error occurs. 143 | */ 144 | + (NSData *)lf_dataFromCGFont:(CGFontRef)cgFont; 145 | 146 | 147 | 148 | @end 149 | -------------------------------------------------------------------------------- /textTools/分类分享/NSDate+LXExtension/NSDate+LXExtension.m: -------------------------------------------------------------------------------- 1 | 2 | #import "NSDate+LXExtension.h" 3 | 4 | //haha? 5 | @implementation LXDateItem 6 | - (NSString *)description 7 | { 8 | return [NSString stringWithFormat:@"%zd天%zd小时%zd分%zd秒", self.day, self.hour, self.minute, self.second]; 9 | } 10 | @end 11 | 12 | @implementation NSDate (LXExtension) 13 | 14 | - (LXDateItem *)lx_timeIntervalSinceDate:(NSDate *)anotherDate 15 | { 16 | // createdAtDate和nowDate之间的时间间隔 17 | NSTimeInterval interval = [self timeIntervalSinceDate:anotherDate]; 18 | 19 | LXDateItem *item = [[LXDateItem alloc] init]; 20 | 21 | // 相差多少天 22 | int intInterval = (int)interval; 23 | int secondsPerDay = 24 * 3600; 24 | item.day = intInterval / secondsPerDay; 25 | 26 | // 相差多少小时 27 | int secondsPerHour = 3600; 28 | item.hour = (intInterval % secondsPerDay) / secondsPerHour; 29 | 30 | // 相差多少分钟 31 | int secondsPerMinute = 60; 32 | item.minute = ((intInterval % secondsPerDay) % secondsPerHour) / secondsPerMinute; 33 | 34 | // 相差多少秒 35 | item.second = ((intInterval % secondsPerDay) % secondsPerHour) % secondsPerMinute; 36 | 37 | return item; 38 | } 39 | 40 | - (BOOL)lx_isToday 41 | { 42 | // 判断self这个日期对象是否为今天 43 | NSCalendar *calendar = [NSCalendar currentCalendar]; 44 | 45 | NSCalendarUnit unit = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay; 46 | 47 | NSDateComponents *selfCmps = [calendar components:unit fromDate:self]; 48 | NSDateComponents *nowCmps = [calendar components:unit fromDate:[NSDate date]]; 49 | 50 | // 如果selfCmps和nowCmps的所有元素都一样,就返回YES,否则返回NO 51 | return [selfCmps isEqual:nowCmps]; 52 | // return selfCmps.year == nowCmps.year 53 | // && selfCmps.month == nowCmps.month 54 | // && selfCmps.day == nowCmps.day; 55 | } 56 | 57 | 58 | - (BOOL)lx_isYesterday 59 | { 60 | // 判断self这个日期对象是否为昨天 61 | 62 | // self 2015-12-09 22:10:01 -> 2015-12-09 00:00:00 63 | // now 2015-12-10 12:10:01 -> 2015-12-01 00:00:00 64 | // 昨天:0year 0month 1day 0hour 0minute 0second 65 | 66 | 67 | // NSDate * -> NSString * -> NSDate * 68 | 69 | NSDateFormatter *fmt = [[NSDateFormatter alloc] init]; 70 | fmt.dateFormat = @"yyyyMMdd"; 71 | 72 | // 生成只有年月日的字符串对象 73 | NSString *selfString = [fmt stringFromDate:self]; 74 | NSString *nowString = [fmt stringFromDate:[NSDate date]]; 75 | 76 | // 生成只有年月日的日期对象 77 | NSDate *selfDate = [fmt dateFromString:selfString]; 78 | NSDate *nowDate = [fmt dateFromString:nowString]; 79 | 80 | NSCalendar *calendar = [NSCalendar currentCalendar]; 81 | NSCalendarUnit unit = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay; 82 | NSDateComponents *cmps = [calendar components:unit fromDate:selfDate toDate:nowDate options:0]; 83 | return cmps.year == 0 84 | && cmps.month == 0 85 | && cmps.day == 1; 86 | } 87 | 88 | - (BOOL)lx_isTomorrow 89 | { 90 | NSDateFormatter *fmt = [[NSDateFormatter alloc] init]; 91 | fmt.dateFormat = @"yyyyMMdd"; 92 | 93 | // 生成只有年月日的字符串对象 94 | NSString *selfString = [fmt stringFromDate:self]; 95 | NSString *nowString = [fmt stringFromDate:[NSDate date]]; 96 | 97 | // 生成只有年月日的日期对象 98 | NSDate *selfDate = [fmt dateFromString:selfString]; 99 | NSDate *nowDate = [fmt dateFromString:nowString]; 100 | 101 | NSCalendar *calendar = [NSCalendar currentCalendar]; 102 | NSCalendarUnit unit = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay; 103 | NSDateComponents *cmps = [calendar components:unit fromDate:selfDate toDate:nowDate options:0]; 104 | return cmps.year == 0 105 | && cmps.month == 0 106 | && cmps.day == -1; 107 | } 108 | 109 | - (BOOL)lx_isThisYear 110 | { 111 | // 判断self这个日期对象是否为今年 112 | NSCalendar *calendar = [NSCalendar currentCalendar]; 113 | 114 | NSInteger selfYear = [calendar components:NSCalendarUnitYear fromDate:self].year; 115 | NSInteger nowYear = [calendar components:NSCalendarUnitYear fromDate:[NSDate date]].year; 116 | 117 | return selfYear == nowYear; 118 | } 119 | 120 | //获取今天周几 121 | - (NSInteger)getNowWeekday { 122 | NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; 123 | NSDateComponents *comps = [[NSDateComponents alloc] init]; 124 | NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit | 125 | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit; 126 | NSDate *now = [NSDate date]; 127 | // 话说在真机上需要设置区域,才能正确获取本地日期,天朝代码:zh_CN 128 | calendar.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"]; 129 | comps = [calendar components:unitFlags fromDate:now]; 130 | return [comps day]; 131 | } 132 | @end 133 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIDevice+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIDevice+Add.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-3. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | /** 12 | Provides extensions for `UIDevice`. 13 | */ 14 | 15 | typedef void (^ cameraAuthorziedBlock) (void); 16 | 17 | @interface UIDevice (LFAdditions) 18 | 19 | 20 | 21 | #pragma mark - Device Information 22 | ///============================================================================= 23 | /// @name Device Information 24 | ///============================================================================= 25 | 26 | /// Whether the device is iPad/iPad mini. 27 | @property (nonatomic, readonly, getter=lf_isPad) BOOL isPad; 28 | 29 | /// Whether the device is a simulator. 30 | @property (nonatomic, readonly, getter=lf_isSimulator) BOOL isSimulator; 31 | 32 | /// Wherher the device can make phone calls. 33 | @property (nonatomic, readonly, getter=lf_canMakePhoneCalls) BOOL canMakePhoneCalls; 34 | 35 | /// The device's machine model. e.g. "iPhone6,1" "iPad4,6" 36 | /// @see http://theiphonewiki.com/wiki/Models 37 | @property (nonatomic, readonly, getter=lf_machineModel) NSString *machineModel; 38 | 39 | /// The device's machine model name. e.g. "iPhone 5s" "iPad mini 2" 40 | /// @see http://theiphonewiki.com/wiki/Models 41 | @property (nonatomic, readonly, getter=lf_machineModelName) NSString *machineModelName; 42 | 43 | /// 屏幕大小,高大于宽 44 | + (CGSize) lf_screenSize; 45 | 46 | /// 系统版本,以float形式返回 47 | - (CGFloat)lf_systemVersionByFloat; 48 | 49 | /// 系统版本,以float形式返回 50 | + (CGFloat)lf_systemVersionByFloat; 51 | 52 | #pragma mark - Disk Space 53 | ///============================================================================= 54 | /// @name Disk Space 55 | ///============================================================================= 56 | 57 | /// Total disk space in byte. (-1 when error occurs) 58 | @property (nonatomic, readonly, getter=lf_diskSpace) int64_t diskSpace; 59 | 60 | /// Free disk space in byte. (-1 when error occurs) 61 | @property (nonatomic, readonly, getter=lf_diskSpaceFree) int64_t diskSpaceFree; 62 | 63 | /// Used disk space in byte. (-1 when error occurs) 64 | @property (nonatomic, readonly, getter=lf_diskSpaceUsed) int64_t diskSpaceUsed; 65 | 66 | 67 | #pragma mark - Memory Information 68 | ///============================================================================= 69 | /// @name Memory Information 70 | ///============================================================================= 71 | 72 | /// Total physical memory in byte. (-1 when error occurs) 73 | @property (nonatomic, readonly, getter=lf_memoryTotal) int64_t memoryTotal; 74 | 75 | /// Used (active + inactive + wired) memory in byte. (-1 when error occurs) 76 | @property (nonatomic, readonly, getter=lf_memoryUsed) int64_t memoryUsed; 77 | 78 | /// Free memory in byte. (-1 when error occurs) 79 | @property (nonatomic, readonly, getter=lf_memoryFree) int64_t memoryFree; 80 | 81 | /// Acvite memory in byte. (-1 when error occurs) 82 | @property (nonatomic, readonly, getter=lf_memoryActive) int64_t memoryActive; 83 | 84 | /// Inactive memory in byte. (-1 when error occurs) 85 | @property (nonatomic, readonly, getter=lf_memoryInactive) int64_t memoryInactive; 86 | 87 | /// Wired memory in byte. (-1 when error occurs) 88 | @property (nonatomic, readonly, getter=lf_memoryWired) int64_t memoryWired; 89 | 90 | /// Purgable memory in byte. (-1 when error occurs) 91 | @property (nonatomic, readonly, getter=lf_memoryPurgable) int64_t memoryPurgable; 92 | 93 | @property (nonatomic,copy ,readonly, getter=lf_CPUType) NSString *CPUType; 94 | @property (nonatomic,copy ,readonly, getter=lf_CPUSubtype) NSString *CPUSubtype; 95 | 96 | 97 | #pragma mark - System version compare 98 | ///============================================================================= 99 | /// @name System version compare 100 | ///============================================================================= 101 | 102 | - (BOOL)lf_systemVersionLowerThan:(NSString*)version; 103 | - (BOOL)lf_systemVersionNotHigherThan:(NSString *)version; 104 | - (BOOL)lf_systemVersionHigherThan:(NSString*)version; 105 | - (BOOL)lf_systemVersionNotLowerThan:(NSString *)version; 106 | 107 | #pragma mark - Others 108 | ///============================================================================= 109 | /// @name Others 110 | ///============================================================================= 111 | 112 | /// 设备是否越狱 113 | /// Whether the device is jailbroken. 114 | @property (nonatomic, readonly, getter=lf_isJailbroken) BOOL isJailbroken; 115 | 116 | // 117 | + (void)lf_cameraAuthorzied:(cameraAuthorziedBlock)authorizedBlock notAuthorized:(cameraAuthorziedBlock)notAuthorizedlock; 118 | -(NSString*)lf_deviceID; 119 | 120 | @end 121 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSData+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSData+LFAdd.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-4. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | 哈希,加密,解码等功能 13 | */ 14 | @interface NSData (LFHashAdditions) 15 | 16 | #pragma mark - Hash 17 | ///============================================================================= 18 | /// @name Hash 19 | ///============================================================================= 20 | 21 | /// md5 小写 22 | - (NSString *)lf_md5; 23 | 24 | /// md2 小写 25 | - (NSString *)lf_md2String; 26 | /// md4 小写 27 | - (NSString *)lf_md4String; 28 | /// md5 小写 29 | - (NSString *)lf_md5String; 30 | /// sha1 小写 31 | - (NSString *)lf_sha1String; 32 | /// sha224 小写 33 | - (NSString *)lf_sha224String; 34 | /// sha256 小写 35 | - (NSString *)lf_sha256String; 36 | /// sha384 小写 37 | - (NSString *)lf_sha384String; 38 | /// sha512 小写 39 | - (NSString *)lf_sha512String; 40 | 41 | /// md2 NSData 42 | - (NSData *)lf_md2Data; 43 | /// md4 NSData 44 | - (NSData *)lf_md4Data; 45 | /// md5 NSData 46 | - (NSData *)lf_md5Data; 47 | /// sha1 NSData 48 | - (NSData *)lf_sha1Data; 49 | /// sha224 NSData 50 | - (NSData *)lf_sha224Data; 51 | /// sha256 NSData 52 | - (NSData *)lf_sha256Data; 53 | /// sha384 NSData 54 | - (NSData *)lf_sha384Data; 55 | /// sha512 NSData 56 | - (NSData *)lf_sha512Data; 57 | 58 | 59 | /// hmac (md5) 小写 60 | - (NSString *)lf_hmacMD5StringWithKey:(NSString *)key; 61 | /// hmac (sha1) 小写 62 | - (NSString *)lf_hmacSHA1StringWithKey:(NSString *)key; 63 | /// hmac (sha224) 小写 64 | - (NSString *)lf_hmacSHA224StringWithKey:(NSString *)key; 65 | /// hmac (sha256) 小写 66 | - (NSString *)lf_hmacSHA256StringWithKey:(NSString *)key; 67 | /// hmac (sha384) 小写 68 | - (NSString *)lf_hmacSHA384StringWithKey:(NSString *)key; 69 | /// hmac (sha512) 小写 70 | 71 | - (NSString *)lf_hmacSHA512StringWithKey:(NSString *)key; 72 | /// hmac (md5) NSData 73 | - (NSData *)lf_hmacMD5DataWithKey:(NSData *)key; 74 | /// hmac (sha1) NSData 75 | - (NSData *)lf_hmacSHA1DataWithKey:(NSData *)key; 76 | /// hmac (sha224) NSData 77 | - (NSData *)lf_hmacSHA224DataWithKey:(NSData *)key; 78 | /// hmac (sha256) NSData 79 | - (NSData *)lf_hmacSHA256DataWithKey:(NSData *)key; 80 | /// hmac (sha384) NSData 81 | - (NSData *)lf_hmacSHA384DataWithKey:(NSData *)key; 82 | /// hmac (sha512) NSData 83 | - (NSData *)lf_hmacSHA512DataWithKey:(NSData *)key; 84 | 85 | 86 | /// crc32 小写 87 | - (NSString *)lf_crc32String; 88 | /// crc32 89 | - (uint32_t)lf_crc32; 90 | 91 | #pragma mark - Others 92 | ///============================================================================= 93 | /// @name Others 94 | ///============================================================================= 95 | 96 | /// 从 main bundle 里加载数据 (和 [UIImage imageNamed:] 类似). 97 | - (NSData *)lf_dataNamed:(NSString *)name; 98 | 99 | @end 100 | 101 | @interface NSData (LFEncryptionAdditions) 102 | 103 | #pragma mark - 加密解密 104 | ///============================================================================= 105 | /// @name 加密解密 106 | ///============================================================================= 107 | 108 | /// aes 加密 109 | /// @param key 加密的key,长度必须是16/24/32 (128/192/256 bits) 110 | /// @param iv 初始向量,长度必须是16 (128 bits), 允许nil。 111 | /// @return 加密成功返回NSData,否则返回nil 112 | - (NSData *)lf_aes256EncryptWithKey:(NSData *)key iv:(NSData *)iv; 113 | 114 | /// aes 解密 115 | /// @param key 加密的key,长度必须是16/24/32 (128/192/256 bits) 116 | /// @param iv 初始向量,长度必须是16 (128 bits), 允许nil。 117 | /// @return 解密成功返回NSData,否则返回nil 118 | - (NSData *)lf_aes256DecryptWithkey:(NSData *)key iv:(NSData *)iv; 119 | 120 | 121 | @end 122 | 123 | @interface NSData (LFEncodeAddditions) 124 | 125 | #pragma mark - 编码解码 126 | ///============================================================================= 127 | /// @name Encode and decode 128 | ///============================================================================= 129 | 130 | 131 | /// 用 UTF8 解码 132 | - (NSString *)lf_utf8String; 133 | 134 | /// 转换为大写 hex 字符串 135 | - (NSString *)lf_hexString; 136 | 137 | /// 用 hex 字符串(不区分大小写)创建NSData。 失败则返回nil。 138 | + (NSData *)lf_dataWithHexString:(NSString *)hexString; 139 | 140 | /// 以json方式解码,返回 NSDictionary 或 NSArray。出错则返回nil 141 | - (id)lf_jsonValueDecoded; 142 | 143 | @end 144 | 145 | @interface NSData (LFCompressionAdditions) 146 | 147 | #pragma mark - 压缩解压 148 | ///============================================================================= 149 | /// @name Inflate and deflate 150 | ///============================================================================= 151 | 152 | /// 解压 gzip 数据 153 | - (NSData *)lf_gzipInflate; 154 | 155 | /// 以 gzip 压缩 156 | - (NSData *)lf_gzipDeflate; 157 | 158 | /// 解压 zlib 数据 159 | - (NSData *)lf_zlibInflate; 160 | 161 | /// 以 zlib 压缩 162 | - (NSData *)lf_zlibDeflate; 163 | 164 | @end 165 | 166 | -------------------------------------------------------------------------------- /textTools/工具类分享/4/LocalPushCenter.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | #import "LocalPushCenter.h" 4 | 5 | @implementation LocalPushCenter 6 | 7 | + (NSDate *)fireDateWithWeek:(NSInteger)week 8 | hour:(NSInteger)hour 9 | minute:(NSInteger)minute 10 | second:(NSInteger)second { 11 | NSCalendar *calendar = [NSCalendar currentCalendar]; 12 | [calendar setTimeZone:[NSTimeZone defaultTimeZone]]; 13 | 14 | unsigned currentFlag = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitSecond; 15 | 16 | NSDateComponents *component = [calendar components:currentFlag fromDate:[NSDate date]]; 17 | 18 | if (week) { 19 | component.weekday = week; 20 | } 21 | if (hour) { 22 | component.hour = hour; 23 | } 24 | 25 | if (minute) { 26 | component.minute = minute; 27 | } 28 | if (second) { 29 | component.second = second; 30 | } else { 31 | component.second = 0; 32 | } 33 | 34 | return [[calendar dateFromComponents:component] dateByAddingTimeInterval:0]; 35 | } 36 | 37 | #pragma mark - 本地推送 38 | + (void)localPushForDate:(NSDate *)fireDate 39 | forKey:(NSString *)key 40 | alertBody:(NSString *)alertBody 41 | alertAction:(NSString *)alertAction 42 | soundName:(NSString *)soundName 43 | launchImage:(NSString *)launchImage 44 | userInfo:(NSDictionary *)userInfo 45 | badgeCount:(NSUInteger)badgeCount 46 | repeatInterval:(NSCalendarUnit)repeatInterval { 47 | UILocalNotification *localNotification = [[UILocalNotification alloc] init]; 48 | if (!localNotification) { 49 | return; 50 | } 51 | 52 | [self cancleLocalPushWithKey:key]; 53 | 54 | NSUInteger notificationType; //UIUserNotificationType(>= iOS8) and UIRemoteNotificatioNType(< iOS8) use same value 55 | UIApplication *application = [UIApplication sharedApplication]; 56 | if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1) { 57 | notificationType = [[application currentUserNotificationSettings] types]; 58 | } else { 59 | notificationType = [application enabledRemoteNotificationTypes]; 60 | } 61 | if (notificationType == UIRemoteNotificationTypeNone) { 62 | return; 63 | } 64 | 65 | // ios8后,需要添加这个注册,才能得到授权 66 | if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) { 67 | UIUserNotificationType type = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound; 68 | UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:type categories:nil]; 69 | [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; 70 | // 通知重复提示的单位,可以是天、周、月 71 | localNotification.alertBody = alertBody; 72 | localNotification.alertAction = alertAction; 73 | localNotification.alertLaunchImage = launchImage; 74 | localNotification.repeatInterval = repeatInterval; 75 | } else { 76 | localNotification.alertBody = alertBody; 77 | localNotification.alertAction = alertAction; 78 | localNotification.alertLaunchImage = launchImage; 79 | localNotification.repeatInterval = repeatInterval; 80 | } 81 | 82 | //Sound 83 | if (soundName) { 84 | localNotification.soundName = soundName; 85 | } else { 86 | localNotification.soundName = UILocalNotificationDefaultSoundName; 87 | } 88 | 89 | //Badge 90 | if ((notificationType & UIRemoteNotificationTypeBadge) != UIRemoteNotificationTypeBadge) { 91 | } else { 92 | localNotification.applicationIconBadgeNumber = badgeCount; 93 | } 94 | 95 | if (!fireDate) { 96 | [[UIApplication sharedApplication] presentLocalNotificationNow:localNotification]; 97 | } else { 98 | localNotification.fireDate = fireDate; 99 | localNotification.timeZone = [NSTimeZone defaultTimeZone]; 100 | [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 101 | } 102 | 103 | } 104 | 105 | #pragma mark - 退出 106 | + (void)cancelAllLocalPhsh { 107 | [[UIApplication sharedApplication] cancelAllLocalNotifications]; 108 | } 109 | 110 | + (void)cancleLocalPushWithKey:(NSString *)key { 111 | NSArray *notiArray = [[UIApplication sharedApplication] scheduledLocalNotifications]; 112 | if (notiArray) { 113 | for (UILocalNotification *notification in notiArray) { 114 | NSDictionary *dic = notification.userInfo; 115 | if (dic) { 116 | for (NSString *key in dic) { 117 | if ([key isEqualToString:key]) { 118 | [[UIApplication sharedApplication] cancelLocalNotification:notification]; 119 | } 120 | } 121 | } 122 | } 123 | } 124 | } 125 | 126 | @end 127 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFNSString+URLString.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Ex.m 3 | // LaiFeng 4 | // 5 | // Created by xinliu on 14-5-16. 6 | // Copyright (c) 2014年 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFNSString+URLString.h" 10 | #import 11 | #import "LFCategory.h" 12 | 13 | @implementation NSString(LFURLStringAdditions) 14 | 15 | /////////////////////////////////////////////////////////////////////////////////////////////////// 16 | - (NSString*) lf_urlEncode2:(NSStringEncoding)stringEncoding 17 | { 18 | 19 | NSArray *escapeChars = [NSArray arrayWithObjects:@";", @"/", @"?", @":", 20 | @"@", @"&", @"=", @"+", @"$", @",", @"!", 21 | @"'", @"(", @")", @"*", @"-", @"~", @"_", nil]; 22 | 23 | NSArray *replaceChars = [NSArray arrayWithObjects:@"%3B", @"%2F", @"%3F", @"%3A", 24 | @"%40", @"%26", @"%3D", @"%2B", @"%24", @"%2C", @"%21", 25 | @"%27", @"%28", @"%29", @"%2A", @"%2D", @"%7E", @"%5F", nil]; 26 | 27 | NSInteger len = [escapeChars count]; 28 | 29 | NSString *tempStr = [self stringByAddingPercentEscapesUsingEncoding:stringEncoding]; 30 | 31 | if (tempStr == nil) { 32 | return nil; 33 | } 34 | 35 | NSMutableString *temp = [tempStr mutableCopy]; 36 | 37 | int i; 38 | for (i = 0; i < len; i++) { 39 | 40 | [temp replaceOccurrencesOfString:[escapeChars objectAtIndex:i] 41 | withString:[replaceChars objectAtIndex:i] 42 | options:NSLiteralSearch 43 | range:NSMakeRange(0, [temp length])]; 44 | } 45 | 46 | NSString *outStr = [NSString stringWithString: temp]; 47 | 48 | return outStr; 49 | } 50 | 51 | // 判断字符串是否为空 52 | + (BOOL)lf_stringIsNull:(NSString *)string 53 | { 54 | if (!string) { 55 | return YES; 56 | } else if ([string isEqualToString:@""] || [string isEqualToString:@"(null)"]){ 57 | return YES; 58 | } 59 | NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet]; 60 | string = [string stringByTrimmingCharactersInSet:whitespace]; 61 | if (string && ![string isEqualToString:@""] && ![string isEqualToString:@"(null)"]) { 62 | return NO; 63 | } else { 64 | return YES; 65 | } 66 | } 67 | 68 | - (NSString*) lf_urlDecode:(NSStringEncoding)stringEncoding 69 | { 70 | 71 | NSArray *escapeChars = [NSArray arrayWithObjects:@";", @"/", @"?", @":", 72 | @"@", @"&", @"=", @"+", @"$", @",", @"!", 73 | @"'", @"(", @")", @"*", @"-", @"~", @"_", nil]; 74 | 75 | NSArray *replaceChars = [NSArray arrayWithObjects:@"%3B", @"%2F", @"%3F", @"%3A", 76 | @"%40", @"%26", @"%3D", @"%2B", @"%24", @"%2C", @"%21", 77 | @"%27", @"%28", @"%29", @"%2A", @"%2D", @"%7E", @"%5F", nil]; 78 | 79 | NSInteger len = [escapeChars count]; 80 | 81 | NSMutableString *temp = [self mutableCopy]; 82 | 83 | if (temp == nil) { 84 | return nil; 85 | } 86 | 87 | int i; 88 | for (i = 0; i < len; i++) { 89 | 90 | [temp replaceOccurrencesOfString:[replaceChars objectAtIndex:i] 91 | withString:[escapeChars objectAtIndex:i] 92 | options:NSLiteralSearch 93 | range:NSMakeRange(0, [temp length])]; 94 | } 95 | NSString *outStr = [NSString stringWithString: temp]; 96 | 97 | return [outStr stringByReplacingPercentEscapesUsingEncoding:stringEncoding]; 98 | } 99 | 100 | - (NSDictionary*)lf_queryContentsDicUsingEncoding:(NSStringEncoding)encoding { 101 | NSCharacterSet* delimiterSet = [NSCharacterSet characterSetWithCharactersInString:@"&;"]; 102 | NSMutableDictionary* pairs = [NSMutableDictionary dictionary]; 103 | NSScanner* scanner = [[NSScanner alloc] initWithString:self]; 104 | while (![scanner isAtEnd]) { 105 | NSString* pairString = nil; 106 | [scanner scanUpToCharactersFromSet:delimiterSet intoString:&pairString]; 107 | [scanner scanCharactersFromSet:delimiterSet intoString:NULL]; 108 | NSArray* kvPair = [pairString componentsSeparatedByString:@"="]; 109 | if (kvPair.count == 2) { 110 | NSString* key = [[kvPair objectAtIndex:0] 111 | stringByReplacingPercentEscapesUsingEncoding:encoding]; 112 | NSString* value = [[kvPair objectAtIndex:1] 113 | stringByReplacingPercentEscapesUsingEncoding:encoding]; 114 | [pairs setObject:value forKey:key]; 115 | } 116 | } 117 | return [NSDictionary dictionaryWithDictionary:pairs]; 118 | } 119 | 120 | 121 | - (NSURL *)lf_toURL { 122 | if ([self lf_isNotBlank]) { 123 | return [NSURL URLWithString:self]; 124 | } 125 | return nil; 126 | } 127 | 128 | @end 129 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFALAsset+Image.m: -------------------------------------------------------------------------------- 1 | // 2 | // LFALAsset+Image.m 3 | // LFCategory 4 | // 5 | // Created by WangZhiWei on 16/5/19. 6 | // Copyright © 2016年 youku. All rights reserved. 7 | // 8 | 9 | #import "LFALAsset+Image.h" 10 | #import "LFCategoryMacro.h" 11 | #import 12 | #import "LFUIImage+Scale.h" 13 | 14 | 15 | @implementation ALAsset (LFALAssetImageAdditions) 16 | 17 | const CGFloat kHDImageMaxLength = 1204.0f; // 高清图片最大的长度(长度和宽度) 18 | const CGFloat kHDImageMaxHeight = 12040.0f; // 高清图片最大的高度 19 | 20 | // 获取原始图片 21 | - (UIImage *)lf_fullSizeImage 22 | { 23 | return [self imageForMaxSize:kHDImageMaxLength]; 24 | } 25 | 26 | // 获取全屏尺寸的照片 27 | - (UIImage *)lf_fullScreenImage 28 | { 29 | return [UIImage imageWithCGImage:[self.defaultRepresentation fullScreenImage]]; 30 | } 31 | 32 | #pragma mark - private methods 33 | 34 | // 获取maxSize大小的图片 35 | - (UIImage *)imageForMaxSize:(CGFloat)maxSize 36 | { 37 | ALAssetRepresentation *assetRepresentation = self.defaultRepresentation; 38 | if ([assetRepresentation.metadata objectForKey:@"AdjustmentXMP"]) { 39 | //解析图片裁剪信息,发送的时候需要手动兼容,系统相机的裁剪,以便发送裁剪之后的图片 40 | //不如直接久返回屏幕大小的图片不会有影响用户体验,否则解析AdjustmentXMPH比较麻烦 41 | return [UIImage imageWithCGImage:[assetRepresentation fullScreenImage]]; 42 | } 43 | UIImage *image = [self originImageForMaxSize:maxSize]; 44 | if(!image) image = [UIImage imageWithCGImage:[assetRepresentation fullScreenImage]]; 45 | return image; 46 | } 47 | 48 | // 根据maxSize裁剪图片大小 49 | - (UIImage *)originImageForMaxSize:(CGFloat)maxSize 50 | { 51 | NSTimeInterval time = [[NSDate date]timeIntervalSince1970]; 52 | ALAsset *asset = self; 53 | ALAssetRepresentation *assetRepresentation = asset.defaultRepresentation; 54 | UIImage *result = nil; 55 | NSData *data = nil; 56 | 57 | uint8_t *buffer = (uint8_t *)malloc((size_t)(sizeof(uint8_t)*[assetRepresentation size])); 58 | if (buffer != NULL) { 59 | NSError *error = nil; 60 | NSUInteger bytesRead = (NSUInteger)[assetRepresentation getBytes:buffer fromOffset:0 length:(NSUInteger)[assetRepresentation size] error:&error]; 61 | data = [NSData dataWithBytes:buffer length:bytesRead]; 62 | if (error) { 63 | _UTKDevLog(@"读取照片错误 %@",error.localizedDescription); 64 | } 65 | free(buffer); 66 | } 67 | 68 | if ([data length]) { 69 | CGImageSourceRef sourceRef = CGImageSourceCreateWithData((__bridge CFDataRef)data, nil); 70 | NSMutableDictionary *options = [NSMutableDictionary dictionary]; 71 | [options setObject:(id)kCFBooleanTrue 72 | forKey:(id)kCGImageSourceShouldAllowFloat]; 73 | [options setObject:(id)kCFBooleanTrue 74 | forKey:(id)kCGImageSourceCreateThumbnailFromImageAlways]; 75 | 76 | CGFloat width; 77 | CGFloat height; 78 | CGSize size = CGSizeZero; 79 | if ([assetRepresentation respondsToSelector:@selector(dimensions)]) { 80 | size = [assetRepresentation dimensions]; 81 | }else{ 82 | size = [UIImage lf_imageSizeWithData:data]; 83 | } 84 | width = size.width; 85 | height = size.height; 86 | 87 | CGFloat newHeight = maxSize; 88 | CGFloat newWidth = maxSize; 89 | //超宽和超长图片需要放宽最大限制 90 | if (width / height >= kSuperImageRatio || height / width >= kSuperImageRatio) { 91 | if (width > kHDImageMaxLength) { 92 | newWidth = kHDImageMaxLength; 93 | newHeight = height / width * newWidth; 94 | }else{ 95 | newWidth = width; 96 | newHeight = height; 97 | } 98 | } 99 | //最大的长图高度10240防止上传超大图片 100 | if (newHeight > kHDImageMaxHeight) { 101 | newHeight = kHDImageMaxHeight; 102 | newWidth = newHeight * width / height ; 103 | } 104 | 105 | //设置最大的读入图片大小 106 | CGFloat newMaxSize = MAX(newHeight, newWidth); 107 | [options setObject:(id)[NSNumber numberWithFloat:newMaxSize] 108 | forKey:(id)kCGImageSourceThumbnailMaxPixelSize]; 109 | CGImageRef imageRef = CGImageSourceCreateThumbnailAtIndex(sourceRef, 110 | 0, 111 | (__bridge CFDictionaryRef)options); 112 | if (imageRef) { 113 | result = [UIImage imageWithCGImage:imageRef 114 | scale:[assetRepresentation scale] 115 | orientation:(UIImageOrientation)[assetRepresentation orientation]]; 116 | CGImageRelease(imageRef); 117 | } 118 | 119 | if (sourceRef) CFRelease(sourceRef); 120 | } 121 | _UTKDevLog(@"读入的原始图片大小为:%@",NSStringFromCGSize(result.size)); 122 | time = [[NSDate date] timeIntervalSince1970] - time; 123 | _UTKDevLog(@"maxSize %f 图片读入的时间为 %f",maxSize,time); 124 | return result; 125 | } 126 | 127 | @end 128 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIView+Add.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+Add.h 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-3. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | Provides extensions for `UIView`. 13 | */ 14 | @interface UIView (LFAdditions) 15 | 16 | /** 17 | Create a snapshot image of the complete view hierarchy. 18 | This method should be called in main thread. 19 | */ 20 | - (UIImage *)lf_snapshotImage; 21 | 22 | /** 23 | Create a snapshot PDF of the complete view hierarchy. 24 | This method should be called in main thread. 25 | */ 26 | - (NSData *)lf_snapshotPDF; 27 | 28 | /** 29 | Shortcut to set the view.layer's shadow 30 | 31 | @param color Shadow Color 32 | @param offset Shadow offset 33 | @param radius Shadow radius 34 | */ 35 | - (void)lf_setLayerShadow:(UIColor*)color offset:(CGSize)offset radius:(CGFloat)radius; 36 | /** 37 | * 设置阴影 郭liyuan+ 38 | */ 39 | - (void) lf_makeInsetShadow; 40 | - (void) lf_makeInsetShadowWithRadius:(float)radius Alpha:(float)alpha; 41 | - (void) lf_makeInsetShadowWithRadius:(float)radius Color:(UIColor *)color Directions:(NSArray *)directions; 42 | 43 | /** 44 | Remove all subviews. 45 | 46 | @warning Never call this method inside your view's drawRect: method. 47 | */ 48 | - (void)lf_removeAllSubviews; 49 | 50 | /** 51 | Returns the view's view controller (may be nil). 52 | */ 53 | @property (nonatomic, readonly, getter=lf_viewController) UIViewController *viewController; 54 | 55 | @property (nonatomic, setter=setLf_left:, getter=lf_left) CGFloat left; ///< Shortcut for frame.origin.x. 56 | @property (nonatomic, setter=setLf_top:, getter=lf_top) CGFloat top; ///< Shortcut for frame.origin.y 57 | @property (nonatomic, setter=setLf_right:, getter=lf_right) CGFloat right; ///< Shortcut for frame.origin.x + frame.size.width 58 | @property (nonatomic, setter=setLf_bottom:, getter=lf_bottom) CGFloat bottom; ///< Shortcut for frame.origin.y + frame.size.height 59 | @property (nonatomic, setter=setLf_width:, getter=lf_width) CGFloat width; ///< Shortcut for frame.size.width. 60 | @property (nonatomic, setter=setLf_height:, getter=lf_height) CGFloat height; ///< Shortcut for frame.size.height. 61 | @property (nonatomic, setter=setLf_centerX:, getter=lf_centerX) CGFloat centerX; ///< Shortcut for center.x 62 | @property (nonatomic, setter=setLf_centerY:, getter=lf_centerY) CGFloat centerY; ///< Shortcut for center.y 63 | @property (nonatomic, setter=setLf_origin:, getter=lf_origin) CGPoint origin; ///< Shortcut for frame.origin. 64 | @property (nonatomic, getter=lf_size, setter=setLf_size: ) CGSize size; ///< Shortcut for frame.size. 65 | @property (nonatomic, readonly) CGRect lf_screenFrame; ///< View frame on the screen, taking into account scroll views. 66 | 67 | /** 68 | Returns the visible alpha on screen, taking into account superview and window. 69 | */ 70 | @property (nonatomic, readonly) CGFloat lf_visibleAlpha; 71 | 72 | 73 | /** 74 | Converts a point from the receiver's coordinate system to that of the specified view or window. 75 | 76 | @param point A point specified in the local coordinate system (bounds) of the receiver. 77 | @param view The view or window into whose coordinate system point is to be converted. 78 | If view is nil, this method instead converts to window base coordinates. 79 | @return The point converted to the coordinate system of view. 80 | */ 81 | - (CGPoint)lf_convertPoint:(CGPoint)point toViewOrWindow:(UIView *)view; 82 | 83 | /** 84 | Converts a point from the coordinate system of a given view or window to that of the receiver. 85 | 86 | @param point A point specified in the local coordinate system (bounds) of view. 87 | @param view The view or window with point in its coordinate system. 88 | If view is nil, this method instead converts from window base coordinates. 89 | @return The point converted to the local coordinate system (bounds) of the receiver. 90 | */ 91 | - (CGPoint)lf_convertPoint:(CGPoint)point fromViewOrWindow:(UIView *)view; 92 | 93 | /** 94 | Converts a rectangle from the receiver's coordinate system to that of another view or window. 95 | 96 | @param rect A rectangle specified in the local coordinate system (bounds) of the receiver. 97 | @param view The view or window that is the target of the conversion operation. If view is nil, this method instead converts to window base coordinates. 98 | @return The converted rectangle. 99 | */ 100 | - (CGRect)lf_convertRect:(CGRect)rect toViewOrWindow:(UIView *)view; 101 | 102 | /** 103 | Converts a rectangle from the coordinate system of another view or window to that of the receiver. 104 | 105 | @param rect A rectangle specified in the local coordinate system (bounds) of view. 106 | @param view The view or window with rect in its coordinate system. 107 | If view is nil, this method instead converts from window base coordinates. 108 | @return The converted rectangle. 109 | */ 110 | - (CGRect)lf_convertRect:(CGRect)rect fromViewOrWindow:(UIView *)view; 111 | 112 | /** 113 | * 返回响应者链上的任意Objc 114 | * 115 | * @param viewControllerCls 需要返回的Obj的类名,为nil时默认返回当前控制器 116 | * 117 | * @return viewController Or needCls 118 | */ 119 | - (nonnull id)lf_viewControllerWithNeedViewOrViewController:(nullable Class)viewControllerCls 120 | ; 121 | 122 | 123 | /// 移除所有子视图中 tableview、scrollview 的 delegate、datasource 124 | - (void)lf_clearScrollViewDelegate; 125 | 126 | 127 | - (void)lf_removeAllGestures; 128 | - (void)lf_removeAllGesturesWithSubViews; 129 | 130 | /// 在 block 内禁用动画 131 | + (void)lf_disableAnimationWithBlock:(void (^)(void))block; 132 | @end 133 | -------------------------------------------------------------------------------- /textTools/textTools/LXCategory/LFUIApplication+Add.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIApplication+LFAdd.m 3 | // 4 | // 5 | // Created by guoyaoyuan on 13-4-4. 6 | // Copyright (c) 2013 live Interactive. All rights reserved. 7 | // 8 | 9 | #import "LFUIApplication+Add.h" 10 | #import "LFNSArray+Add.h" 11 | #import "LFCategoryMacro.h" 12 | #import "LFUIDevice+Add.h" 13 | #include 14 | #include 15 | 16 | 17 | NSString * NSDocumentsPath() 18 | { 19 | return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 20 | NSUserDomainMask, YES) firstObject]; 21 | } 22 | 23 | NSString *NSLibraryPath() { 24 | return [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, 25 | NSUserDomainMask, YES) firstObject]; 26 | } 27 | 28 | NSString *NSCachesPath() { 29 | return [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, 30 | NSUserDomainMask, YES) firstObject]; 31 | } 32 | 33 | @implementation UIApplication (LFAdd) 34 | 35 | - (NSURL *)lf_documentsURL { 36 | return [[[NSFileManager defaultManager] 37 | URLsForDirectory:NSDocumentDirectory 38 | inDomains:NSUserDomainMask] lastObject]; 39 | } 40 | 41 | - (NSURL *)lf_cachesURL { 42 | return [[[NSFileManager defaultManager] 43 | URLsForDirectory:NSCachesDirectory 44 | inDomains:NSUserDomainMask] lastObject]; 45 | } 46 | 47 | - (NSURL *)lf_libraryURL { 48 | return [[[NSFileManager defaultManager] 49 | URLsForDirectory:NSLibraryDirectory 50 | inDomains:NSUserDomainMask] lastObject]; 51 | } 52 | 53 | - (NSString *)lf_appBundleName { 54 | return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]; 55 | } 56 | 57 | - (NSString *)lf_appBundleID { 58 | return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"]; 59 | } 60 | 61 | - (NSString *)lf_appVersion { 62 | return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; 63 | } 64 | 65 | - (NSString *)lf_appBuildVersion { 66 | return [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]; 67 | } 68 | 69 | - (int64_t)lf_memoryUsage { 70 | struct task_basic_info info; 71 | mach_msg_type_number_t size = sizeof(info); 72 | kern_return_t kern = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size); 73 | if (kern != KERN_SUCCESS) return -1; 74 | return info.resident_size; 75 | } 76 | 77 | - (float)lf_cpuUsage { 78 | kern_return_t kr; 79 | task_info_data_t tinfo; 80 | mach_msg_type_number_t task_info_count; 81 | 82 | task_info_count = TASK_INFO_MAX; 83 | kr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)tinfo, &task_info_count); 84 | if (kr != KERN_SUCCESS) { 85 | return -1; 86 | } 87 | 88 | thread_array_t thread_list; 89 | mach_msg_type_number_t thread_count; 90 | 91 | thread_info_data_t thinfo; 92 | mach_msg_type_number_t thread_info_count; 93 | 94 | thread_basic_info_t basic_info_th; 95 | 96 | kr = task_threads(mach_task_self(), &thread_list, &thread_count); 97 | if (kr != KERN_SUCCESS) { 98 | return -1; 99 | } 100 | 101 | long tot_sec = 0; 102 | long tot_usec = 0; 103 | float tot_cpu = 0; 104 | int j; 105 | 106 | for (j = 0; j < thread_count; j++) { 107 | thread_info_count = THREAD_INFO_MAX; 108 | kr = thread_info(thread_list[j], THREAD_BASIC_INFO, 109 | (thread_info_t)thinfo, &thread_info_count); 110 | if (kr != KERN_SUCCESS) { 111 | return -1; 112 | } 113 | 114 | basic_info_th = (thread_basic_info_t)thinfo; 115 | 116 | if (!(basic_info_th->flags & TH_FLAGS_IDLE)) { 117 | tot_sec = tot_sec + basic_info_th->user_time.seconds + basic_info_th->system_time.seconds; 118 | tot_usec = tot_usec + basic_info_th->system_time.microseconds + basic_info_th->system_time.microseconds; 119 | tot_cpu = tot_cpu + basic_info_th->cpu_usage / (float)TH_USAGE_SCALE; 120 | } 121 | } 122 | 123 | kr = vm_deallocate(mach_task_self(), (vm_offset_t)thread_list, thread_count * sizeof(thread_t)); 124 | assert(kr == KERN_SUCCESS); 125 | 126 | return tot_cpu; 127 | } 128 | 129 | 130 | 131 | - (BOOL)lf_isPirated { 132 | if ([[UIDevice currentDevice] lf_isSimulator]) return NO; // Dont't check simulator 133 | 134 | if (getgid() <= 10) return YES; // process ID shouldn't be root 135 | 136 | if ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"SignerIdentity"]) { 137 | return YES; 138 | } 139 | 140 | if (![self __fileExistInMainBundle:@"_CodeSignature"]) { 141 | return YES; 142 | } 143 | 144 | if (![self __fileExistInMainBundle:@"SC_Info"]) { 145 | return YES; 146 | } 147 | 148 | //if someone really want to crack your app, this method is useless.. 149 | //you may change this method's name, encrypt the code and do more check.. 150 | return NO; 151 | } 152 | 153 | - (BOOL)__fileExistInMainBundle:(NSString *)name { 154 | NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; 155 | NSString *path = [NSString stringWithFormat:@"%@/%@", bundlePath, name]; 156 | return [[NSFileManager defaultManager] fileExistsAtPath:path]; 157 | } 158 | 159 | 160 | - (BOOL)lf_isBeingDebugged { 161 | size_t size = sizeof(struct kinfo_proc); 162 | struct kinfo_proc info; 163 | int ret = 0, name[4]; 164 | memset(&info, 0, sizeof(struct kinfo_proc)); 165 | 166 | name[0] = CTL_KERN; 167 | name[1] = KERN_PROC; 168 | name[2] = KERN_PROC_PID; name[3] = getpid(); 169 | 170 | if (ret == (sysctl(name, 4, &info, &size, NULL, 0))) { 171 | return ret != 0; 172 | } 173 | return (info.kp_proc.p_flag & P_TRACED) ? YES : NO; 174 | } 175 | 176 | @end 177 | --------------------------------------------------------------------------------