美文网首页iOS Developer
让iOS开发更快更简单--UIKit Addition

让iOS开发更快更简单--UIKit Addition

作者: 达摩君 | 来源:发表于2017-06-20 23:23 被阅读55次

    众所皆知,平时我们在开发的过程中难免都会用VCR模式(command+C,command +V,command+R),还有一部份就是我们平时积累下来的各种category文件,项目开始编写的时候往项目里一拖。当然根据项目的不同,可能每次都会在category文件里微调。但有些大体的分类基本上每个项目都会用到。所以决定专门建一个cocoapods项目集合管理,有新的好的方法就会集成进去。

    使用方法

    1.直接下载,然后将LEEAddition直接拖到项目中,GitHub地址
    2.使用cocoapods,(怎么安装的话网上教程哈)

    • 在podfile文件加入 pod 'LEEAddition';
    • 然后pod install;
    • 如果报"Unable to find a specification for LEEAddition",请输入pod setup;

    分类内容

    #import "UIView+LEEView.h"
    #import "UIScreen+LEEScreen.h"
    #import "UIColor+LEEColor.h"
    #import "UINavigationController+LEENavigationController.h"
    #import "UITextView+LEETextView.h"
    #import "UITextField+LEETextField.h"
    #import "UILabel+LEELable.h"
    #import "UIImage+LEEImage.h"
    #import "NSString+LEEString.h"
    #import "NSObject+LEENSObject.h"
    #import "NSMutableAttributedString+LEEAttributedString.h"
    #import "NSArray+LEENSArray.h"
    #import "NSDictionary+LEENSDictionary.h"
    

    具体内容

    • UIView Category
    IB_DESIGNABLE
    @interface UIView (LEEView)
    // 简易frame调用
    @property(nonatomic, assign) CGFloat Lee_X;
    @property(nonatomic, assign) CGFloat Lee_Y;
    @property(nonatomic, assign) CGFloat Lee_Width;
    @property(nonatomic, assign) CGFloat Lee_Height;
    @property(nonatomic, assign) CGFloat Lee_CenterX;
    @property(nonatomic, assign) CGFloat Lee_CenterY;
    @property(nonatomic, assign) CGSize Lee_Size;
    // 边框宽度
    @property(nonatomic, assign) IBInspectable CGFloat borderWidth;
    // 边框颜色
    @property(nonatomic, strong) IBInspectable UIColor *borderColor;
    // 圆角
    @property(nonatomic, assign) IBInspectable CGFloat cornerRadius;
    // 返回视图截图
     - (UIImage *)lee_snapshotImage;
    @end
    
    • UITextField Category
     IB_DESIGNABLE
     @interface UITextField (LEETextField)
    // 占位符颜色
     @property(nonatomic, strong) IBInspectable UIColor *placeholderColor;
     @end
    
    • NSObject Category
     @interface NSObject (LEENSObject)
    
     /// 使用字典数组创建当前类对象的数组
     ///
     /// @param array 字典数组
     ///
     /// @return 当前类对象的数组
     + (NSArray *)Lee_objectsWithArray:(NSArray *)array;
    
     /// 返回当前类的属性数组
     ///
     /// @return 属性数组
     + (NSArray *)Lee_propertiesList;
    
     /// 返回当前类的成员变量数组
     ///
     /// @return 成员变量数组
     + (NSArray *)Lee_ivarsList;
     @end
    
    • UINavigationController Category
    @interface UINavigationController (LEENavigationController)
    
     ///用于导航控制器回跳到指定控制器
     - (UIViewController *)findNeedChildController:(Class)clz;
    @end
    
    • UILable Category
    @interface UILabel (LEELable)
     // 创建文本标签
     +  (instancetype)Lee_labelWithText:(NSString *)text fontSize:(CGFloat)fontSize color:(UIColor *)color;
    
     // 改变行间距
     +  (void)Lee_changeLineSpaceForLabel:(UILabel *)label WithSpace:(float)space;
    
     // 改变字间距
     +  (void)Lee_changeWordSpaceForLabel:(UILabel *)label WithSpace:(float)space;
    
     //  改变行间距和字间距
     +  (void)Lee_changeSpaceForLabel:(UILabel *)label withLineSpace: (float)lineSpace WordSpace:(float)wordSpace;
    @end
    
    • UIColor Category
     @interface UIColor (LEEColor)
    
     /**
      使用 16 进制数字创建颜色,例如 0xFF0000 创建红色
      @param hex 16 进制无符号32位整数
      @return 颜色
       */
      + (instancetype)Lee_colorWithHex:(uint32_t)hex;
    
     /**
     随机颜色
     @return 随机颜色
      */
     + (instancetype)Lee_randomColor;
     /**
     使用 R / G / B 数值创建颜色
     @return 颜色
      */
     + (instancetype)Lee_colorWithRed:(uint8_t)red green:(uint8_t)green blue:(uint8_t)blue;
    @end
    
    • UIImage Category
    @interface UIImage (LEEImage)
    /**
     图片裁剪成圆形
     @eturn 圆形图片
     */
     - (instancetype)Lee_circleImage;
     + (instancetype)Lee_circleImageNamed:(NSString *)name;
    // 返回一张抗锯齿图片
    // 本质:在图片生成一个透明为1的像素边框
     - (UIImage *)Lee_imageAntialias;
    /**
     *  根据颜色生成一张图片
     *
     *  @param color 颜色
     *  @param size  图片大小
     *
     *  @return 图片
     */
     + (UIImage *)Lee_imageWithColor:(UIColor *)color size:(CGSize)size;
    /**
     *  生成圆角的图片
     *
     *  @param originImage 原始图片
     *  @param borderColor 边框原色
     *  @param borderWidth 边框宽度
     *
     *  @return 圆形图片
     */
     + (UIImage *)Lee_circleImage:(UIImage *)originImage borderColor:(UIColor *)borderColor borderWidth:(CGFloat)borderWidth;
    /**
     *  生成一张高斯模糊的图片
     *
     *  @param image 原图
     *  @param blur  模糊程度 (0~1)
     *
     *  @return 高斯模糊图片
     */
     + (UIImage *)Lee_blurImage:(UIImage *)image blur:(CGFloat)blur;
    @end
    

    等等等等。。。。。。。
    欢迎大家下载使用,也欢迎大家补充~谢谢。。。

    相关文章

      网友评论

        本文标题:让iOS开发更快更简单--UIKit Addition

        本文链接:https://www.haomeiwen.com/subject/ojzaqxtx.html