KTCategories 0.0.9

KTCategories 0.0.9

测试已测试
语言编程语言 Obj-CObjective C
许可证 MIT
发布最后发布2015年10月

Kyle Truscott维护。



我在很多iOS项目中都会用到的一些代码!

pod 'KTCategories', git: 'https://github.com/keighl/KTCategories.git'

KTUtil.h

+ (NSArray *)visualConstraints:(NSString *)format views:(NSDictionary *)views;
+ (NSLayoutConstraint *)makeThis:(id)object equal:(NSLayoutAttribute *)attr toThat:(id)that;
+ (NSString *)intToString:(int)x;
+ (NSString *)floatToString:(float)x;
+ fallbackAnimateWithDuration:(float)duration
                        delay:(float)delay
       usingSpringWithDamping:(float)damping
        initialSpringVelocity:(float)velocity
                      options:(UIViewAnimationOptions)options
                   animations:(void (^)(void))animations
                   completion:(void (^)(BOOL finished))completion;

UIColor+KTExtras.h

+ (UIColor *)greyColorWithBrightness:(CGFloat)brightness;
+ (UIColor *)greyColorWithBrightness:(CGFloat)brightness alpha:(float)alpha;
+ (UIColor *)colorWithRGBHexString:(NSString *)rgbHexString;
+ (UIColor *)colorWithRGBHexString:(NSString *)rgbHexString alpha:(float)alpha;
- (UIColor *)colorWithAdjustedHue:(CGFloat)hue
                       saturation:(CGFloat)saturation
                       brightness:(CGFloat)brightness
                            alpha:(CGFloat)alpha;

KTEdgeLabel.h

  • 为标签提供可选的edgeInsets属性(用于padding)

KTShapeView.h

  • 为CAShapeLayer提供一个可自动布局的视图

    • (id)initWithShapeLayer:(CAShapeLayer *)shapeLayer

NSArray+KTExtras.h

- (NSArray *)removeDuplicatesUsingKey:(NSString *)key
                         withResolver:(KTDuplicateResolver)resolver;

UIView+KTExtras.h

当不能使用自动布局时使用

锚点

(void)anchorToTop;
(void)anchorToTopWithMargin:(CGFloat)margin;
(void)anchorToTopInRect:(CGRect)rect withMargin:(CGFloat)margin;

(void)anchorToBottom;
(void)anchorToBottomWithMargin:(CGFloat)margin;
(void)anchorToBottomInRect:(CGRect)rect withMargin:(CGFloat)margin;

(void)anchorToLeft;
(void)anchorToLeftWithMargin:(CGFloat)margin;
(void)anchorToLeftInRect:(CGRect)rect withMargin:(CGFloat)margin;

(void)anchorToRight;
(void)anchorToRightInRect:(CGRect)rect withMargin:(CGFloat)margin;
(void)anchorToRightWithMargin:(CGFloat)margin;

(void)anchorToTopOnRect:(CGRect)rect withMargin:(CGFloat)margin;
(void)anchorToBottomOnRect:(CGRect)rect withMargin:(CGFloat)margin;
(void)anchorToLeftOnRect:(CGRect)rect withMargin:(CGFloat)margin;
(void)anchorToRightOnRect:(CGRect)rect withMargin:(CGFloat)margin;

对齐

(void)centerX;
(void)centerXY;
(void)centerY;
(void)centerXYInRect:(CGRect)rect;
(void)centerXInRect:(CGRect)rect;
(void)centerYInRect:(CGRect)rect;
(void)centerXOnRect:(CGRect)rect;
(void)centerYOnRect:(CGRect)rect;

相对定位

(void)placeYAfterView:(UIView *)view withMargin:(CGFloat)margin;
(void)placeXAfterView:(UIView *)view withMargin:(CGFloat)margin;

(void)placeYBeforeView:(UIView *)view withMargin:(CGFloat)margin;
(void)placeXBeforeView:(UIView *)view withMargin:(CGFloat)margin;

微调

(void)padTopBy:(CGFloat)points;
(void)padBottomBy:(CGFloat)points;
(void)padLeftBy:(CGFloat)points;
(void)padRightBy:(CGFloat)points;

圆角半径

(void)roundByWidth;
(void)roundByHeight;
(void)roundBy:(CGFloat)radius;

框架调整

(void)setFrameOriginX:(CGFloat)x;
(void)setFrameOriginY:(CGFloat)y;
(void)setFrameSizeWidth:(CGFloat)width;
(void)setFrameSizeHeight:(CGFloat)height;