链式方法分类
2019-03-23 本文已影响0人
蜗牛的马达
链式方法分类.h文件
@interface UIView (frame)
#pragma mark --- property
// 如果@property在分类里面使用只会自动声明get,set方法,不会实现,并且不会帮你生成成员属性
@property (nonatomic, assign) CGFloat x;
@property (nonatomic, assign) CGFloat y;
@property (nonatomic, assign) CGFloat centerX;
@property (nonatomic, assign) CGFloat centerY;
@property (nonatomic, assign) CGFloat width;
@property (nonatomic, assign) CGFloat height;
@property (nonatomic, assign) CGSize size;
@property (nonatomic, assign) CGPoint origin;
@property (nonatomic, assign) CGFloat bottom;
@property (nonatomic, assign) CGFloat right;
#pragma mark --- chaining method
- (UIView* (^)(CGFloat))lq_x;
- (UIView* (^)(CGFloat))lq_y;
- (UIView* (^)(CGFloat))lq_width;
- (UIView* (^)(CGFloat))lq_height;
- (UIView* (^)(CGSize ))lq_size;
- (UIView* (^)(CGPoint))lq_center;
- (UIView* (^)(CGFloat))lq_centerX;
- (UIView* (^)(CGFloat))lq_centerY;
- (UIView* (^)(CGPoint))lq_origin;
- (UIView* (^)(CGFloat))lq_bottom;
- (UIView* (^)(CGFloat))lq_right;
- (UIView* (^)(CGRect))lq_frame;
- (UIView* (^)(CGRect))lq_bounds;
- (UIView* (^)(CGAffineTransform))lq_transform;
@end
@interface UIView (IBD)
@property (nonatomic,assign) IBInspectable CGFloat borderWidth;
@property (nonatomic,assign) IBInspectable UIColor *borderColor;
@property (nonatomic,assign) IBInspectable CGFloat cornerRadius;
@end
@interface UIView (chain)
- (UIView* (^)(BOOL))lq_clipsToBounds;
- (UIView* (^)(BOOL))lq_opaque;
- (UIView* (^)(BOOL))lq_hidden;
- (UIView* (^)(CGFloat))lq_alpha;
- (UIView* (^)(UIViewContentMode))lq_contentMode;
@end
@interface UILabel (chain)
- (UILabel* (^)(NSString*))lq_text;
- (UILabel* (^)(UIFont*))lq_font;
- (UILabel* (^)(UIColor*))lq_textColor;
- (UILabel* (^)(UIColor*))lq_highlightedTextColor;
- (UILabel* (^)(UIColor*))lq_shadowColor;
- (UILabel* (^)(CGSize))lq_shadowOffset;
- (UILabel* (^)(NSTextAlignment))lq_textAlignment;
- (UILabel* (^)(NSLineBreakMode))lq_lineBreakMode;
- (UILabel* (^)(NSAttributedString*))lq_attributedText;
- (UILabel* (^)(BOOL))lq_highlighted;
- (UILabel* (^)(BOOL))lq_userInteractionEnabled;
- (UILabel* (^)(BOOL))lq_enabled;
- (UILabel* (^)(BOOL))lq_adjustsFontSizeToFitWidth;
- (UILabel* (^)(BOOL))lq_adjustsLetterSpacingToFitWidth;
- (UILabel* (^)(NSInteger))lq_numberOfLines;
- (UILabel* (^)(CGFloat))lq_preferredMaxLayoutWidth;
- (UILabel* (^)(CGFloat))lq_minimumFontSize;
- (UILabel* (^)(NSInteger))lq_tag;
- (UILabel* (^)(BOOL))lq_clipsToBounds;
- (UILabel* (^)(BOOL))lq_opaque;
- (UILabel* (^)(BOOL))lq_hidden;
- (UILabel* (^)(CGFloat))lq_alpha;
- (UILabel* (^)(UIViewContentMode))lq_contentMode;
@end
@interface UIButton (chain)
- (UIButton* (^)(BOOL))lq_enabled;
- (UIButton* (^)(BOOL))lq_selected;
- (UIButton* (^)(BOOL))lq_highlighted;
- (UIButton* (^)(BOOL))lq_adjustsImageWhenHighlighted;
- (UIButton* (^)(BOOL))lq_adjustsImageWhenDisabled;
- (UIButton* (^)(UIControlContentVerticalAlignment))lq_contentVerticalAlignment;
- (UIButton* (^)(UIControlContentHorizontalAlignment))lq_contentHorizontalAlignment;
- (UIButton* (^)(UIEdgeInsets))lq_contentEdgeInsets;
- (UIButton* (^)(UIEdgeInsets))lq_titleEdgeInsets;
- (UIButton* (^)(UIEdgeInsets))lq_imageEdgeInsets;
- (UIButton* (^)(UIColor*))lq_tintColor;
- (UIButton* (^)(NSString*))lq_normalTitle;
- (UIButton* (^)(NSString*))lq_highlightedTitle;
- (UIButton* (^)(NSString*))lq_disabledTitle;
- (UIButton* (^)(NSString*))lq_selectedTitle;
- (UIButton* (^)(UIColor*))lq_normalTitleColor;
- (UIButton* (^)(UIColor*))lq_highlightedTitleColor;
- (UIButton* (^)(UIColor*))lq_disabledTitleColor;
- (UIButton* (^)(UIColor*))lq_selectedTitleColor;
- (UIButton* (^)(UIColor*))lq_normalTitleShadowColor;
- (UIButton* (^)(UIColor*))lq_highlightedTitleShadowColor;
- (UIButton* (^)(UIColor*))lq_disabledTitleShadowColor;
- (UIButton* (^)(UIColor*))lq_selectedTitleShadowColor;
- (UIButton* (^)(UIImage*))lq_normalImage;
- (UIButton* (^)(UIImage*))lq_highlightedImage;
- (UIButton* (^)(UIImage*))lq_disabledImage;
- (UIButton* (^)(UIImage*))lq_selectedImage;
- (UIButton* (^)(UIImage*))lq_normalBackgroundImage;
- (UIButton* (^)(UIImage*))lq_highlightedBackgroundImage;
- (UIButton* (^)(UIImage*))lq_disabledBackgroundImage;
- (UIButton* (^)(UIImage*))lq_selectedBackgroundImage;
- (UIButton* (^)(NSAttributedString*))lq_normalAttributedTitle;
- (UIButton* (^)(NSAttributedString*))lq_highlightedAttributedTitle;
- (UIButton* (^)(NSAttributedString*))lq_disabledAttributedTitle;
- (UIButton* (^)(NSAttributedString*))lq_selectedAttributedTitle;
- (UIButton* (^)(UIFont*))lq_font;
- (UIButton* (^)(NSLineBreakMode))lq_lineBreakMode;
- (UIButton* (^)(BOOL))lq_clipsToBounds;
- (UIButton* (^)(BOOL))lq_opaque;
- (UIButton* (^)(BOOL))lq_hidden;
- (UIButton* (^)(CGFloat))lq_alpha;
- (UIButton* (^)(UIViewContentMode))lq_contentMode;
@end
@interface UITextField (chain)
- (UITextField* (^)(NSString*))lq_text;
- (UITextField* (^)(NSString*))lq_placeholder;
- (UITextField* (^)(NSAttributedString*))lq_attributedText;
- (UITextField* (^)(NSAttributedString*))lq_attributedPlaceholder;
- (UITextField* (^)(UIColor*))lq_textColor;
- (UITextField* (^)(UIFont*))lq_font;
- (UITextField* (^)(NSTextAlignment))lq_textAlignment;
- (UITextField* (^)(UITextBorderStyle))lq_borderStyle;
- (UITextField* (^)(BOOL))lq_clearsOnBeginEditing;
- (UITextField* (^)(BOOL))lq_adjustsFontSizeToFitWidth;
- (UITextField* (^)(CGFloat))lq_minimumFontSize;
- (UITextField* (^)(UIImage*))lq_background;
- (UITextField* (^)(UIImage*))lq_disabledBackground;
- (UITextField* (^)(UIView*))lq_leftView;
- (UITextField* (^)(UIView*))lq_rightView;
- (UITextField* (^)(UITextFieldViewMode))lq_clearButtonMode;
- (UITextField* (^)(UITextFieldViewMode))lq_leftViewMode;
- (UITextField* (^)(UITextFieldViewMode))lq_rightViewMode;
@end
链式方法分类.m文件
@implementation UIView (frame)
- (void)setX:(CGFloat)x {
CGRect frame = self.frame;
frame.origin.x = x;
self.frame = frame;
}
- (void)setY:(CGFloat)y {
CGRect frame = self.frame;
frame.origin.y = y;
self.frame = frame;
}
- (CGFloat)x {
return self.frame.origin.x;
}
- (CGFloat)y {
return self.frame.origin.y;
}
- (void)setCenterX:(CGFloat)centerX {
CGPoint center = self.center;
center.x = centerX;
self.center = center;
}
- (CGFloat)centerX {
return self.center.x;
}
- (void)setCenterY:(CGFloat)centerY {
CGPoint center = self.center;
center.y = centerY;
self.center = center;
}
- (CGFloat)centerY {
return self.center.y;
}
- (void)setWidth:(CGFloat)width {
CGRect frame = self.frame;
frame.size.width = width;
self.frame = frame;
}
- (void)setHeight:(CGFloat)height {
CGRect frame = self.frame;
frame.size.height = height;
self.frame = frame;
}
- (CGFloat)height {
return self.frame.size.height;
}
- (CGFloat)width {
return self.frame.size.width;
}
- (void)setSize:(CGSize)size {
CGRect frame = self.frame;
frame.size = size;
self.frame = frame;
}
- (CGSize)size {
return self.frame.size;
}
- (void)setOrigin:(CGPoint)origin {
CGRect frame = self.frame;
frame.origin = origin;
self.frame = frame;
}
- (CGPoint)origin {
return self.frame.origin;
}
- (CGFloat)bottom {
return CGRectGetMaxY(self.frame);
}
- (void)setBottom:(CGFloat)bottom {
self.y = bottom-self.height;
}
- (CGFloat)right {
return CGRectGetMaxX(self.frame);
}
- (void)setRight:(CGFloat)right {
self.x = right-self.width;
}
#pragma mark --- chaining method
- (UIView* (^)(CGFloat))lq_x {
return ^(CGFloat value) {
CGRect frame = self.frame;
self.frame = CGRectMake(value, frame.origin.y, frame.size.width, frame.size.height);
return self;
};
}
- (UIView* (^)(CGFloat))lq_y {
return ^(CGFloat value) {
CGRect frame = self.frame;
self.frame = CGRectMake(frame.origin.x, value, frame.size.width, frame.size.height);
return self;
};
}
- (UIView* (^)(CGFloat))lq_width {
return ^(CGFloat value) {
CGRect frame = self.frame;
self.frame = CGRectMake(frame.origin.x, frame.origin.y, value, frame.size.height);
return self;
};
}
- (UIView* (^)(CGFloat))lq_height {
return ^(CGFloat value) {
CGRect frame = self.frame;
self.frame = CGRectMake(frame.origin.x, frame.origin.y, self.frame.size.width, value);
return self;
};
}
- (UIView* (^)(CGSize))lq_size {
return ^(CGSize size) {
CGRect frame = self.frame;
self.frame = CGRectMake(frame.origin.x, frame.origin.y, size.width, size.height);
return self;
};
}
- (UIView* (^)(CGPoint))lq_center {
return ^(CGPoint point) {
self.center = point;
return self;
};
}
- (UIView* (^)(CGFloat))lq_centerX {
return ^(CGFloat value) {
self.center = CGPointMake(value, self.center.y);
return self;
};
}
- (UIView* (^)(CGFloat))lq_centerY {
return ^(CGFloat value) {
self.center = CGPointMake(self.center.x, value);
return self;
};
}
- (UIView* (^)(CGPoint))lq_origin {
return ^(CGPoint point) {
self.frame = CGRectMake(point.x, point.y, self.frame.size.width, self.frame.size.height);
return self;
};
}
- (UIView* (^)(CGFloat))lq_bottom {
return ^(CGFloat value) {
self.frame = CGRectMake(self.frame.origin.x, value-self.frame.size.height, self.frame.size.width, self.frame.size.height);
return self;
};
}
- (UIView* (^)(CGFloat))lq_right {
return ^(CGFloat value) {
self.frame = CGRectMake(value-self.frame.size.width, self.frame.origin.y, self.frame.size.width, self.frame.size.height);
return self;
};
}
- (UIView* (^)(CGRect))lq_frame {
return ^(CGRect value) {
self.frame = value;
return self;
};
}
- (UIView* (^)(CGRect))lq_bounds {
return ^(CGRect value) {
self.bounds = value;
return self;
};
}
- (UIView* (^)(CGAffineTransform))lq_transform {
return ^(CGAffineTransform value) {
self.transform = value;
return self;
};
}
@end
@implementation UIView (IBD)
// setter for corner Radius
- (void)setCornerRadius:(CGFloat)cornerRadius {
self.layer.masksToBounds = YES;
self.layer.cornerRadius = cornerRadius;
}
- (CGFloat)cornerRadius {
return self.layer.cornerRadius;
}
// setter for borderColor
- (void)setBorderColor:(UIColor *)borderColor {
self.layer.borderColor = borderColor.CGColor;
}
- (UIColor*)borderColor {
return [UIColor colorWithCGColor:self.layer.borderColor];
}
// setter for borderWidth
- (void)setBorderWidth:(CGFloat)borderWidth {
self.layer.borderWidth = borderWidth;
}
- (CGFloat)borderWidth {
return self.layer.borderWidth;
}
@end
@implementation UIView (chain)
- (UIView* (^)(BOOL))lq_clipsToBounds {
return ^(BOOL value) {
self.clipsToBounds = value;
return self;
};
}
- (UIView* (^)(BOOL))lq_opaque {
return ^(BOOL value) {
self.opaque = value;
return self;
};
}
- (UIView* (^)(BOOL))lq_hidden {
return ^(BOOL value) {
self.hidden = value;
return self;
};
}
- (UIView* (^)(CGFloat))lq_alpha {
return ^(CGFloat value) {
self.alpha = value;
return self;
};
}
- (UIView* (^)(UIViewContentMode))lq_contentMode {
return ^(UIViewContentMode value) {
self.contentMode = value;
return self;
};
}
@end
@implementation UILabel (chain)
- (UILabel* (^)(NSString*))lq_text {
return ^(NSString* value) {
self.text = value;
return self;
};
}
- (UILabel* (^)(UIFont*))lq_font {
return ^(UIFont* value) {
self.font = value;
return self;
};
}
- (UILabel* (^)(UIColor*))lq_textColor {
return ^(UIColor* value) {
self.textColor = value;
return self;
};
}
- (UILabel* (^)(UIColor*))lq_shadowColor {
return ^(UIColor* value) {
self.shadowColor = value;
return self;
};
}
- (UILabel* (^)(CGSize))lq_shadowOffset {
return ^(CGSize value) {
self.shadowOffset = value;
return self;
};
}
- (UILabel* (^)(NSTextAlignment))lq_textAlignment {
return ^(NSTextAlignment value) {
self.textAlignment = value;
return self;
};
}
- (UILabel* (^)(NSLineBreakMode))lq_lineBreakMode {
return ^(NSLineBreakMode value) {
self.lineBreakMode = value;
return self;
};
}
- (UILabel* (^)(NSAttributedString*))lq_attributedText {
return ^(NSAttributedString* value) {
self.attributedText = value;
return self;
};
}
- (UILabel* (^)(UIColor*))lq_highlightedTextColor {
return ^(UIColor* value) {
self.highlightedTextColor = value;
return self;
};
}
- (UILabel* (^)(BOOL))lq_highlighted {
return ^(BOOL value) {
self.highlighted = value;
return self;
};
}
- (UILabel* (^)(BOOL))lq_userInteractionEnabled {
return ^(BOOL value) {
self.userInteractionEnabled = value;
return self;
};
}
- (UILabel* (^)(BOOL))lq_enabled {
return ^(BOOL value) {
self.enabled = value;
return self;
};
}
- (UILabel* (^)(NSInteger))lq_numberOfLines {
return ^(NSInteger value) {
self.numberOfLines = value;
return self;
};
}
- (UILabel* (^)(BOOL))lq_adjustsFontSizeToFitWidth {
return ^(BOOL value) {
self.adjustsFontSizeToFitWidth = value;
return self;
};
}
- (UILabel* (^)(CGFloat))lq_preferredMaxLayoutWidth {
return ^(CGFloat value) {
self.preferredMaxLayoutWidth = value;
return self;
};
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (UILabel* (^)(CGFloat))lq_minimumFontSize {
return ^(CGFloat value) {
self.minimumFontSize = value;
return self;
};
}
- (UILabel* (^)(BOOL))lq_adjustsLetterSpacingToFitWidth {
return ^(BOOL value) {
self.adjustsLetterSpacingToFitWidth = value;
return self;
};
}
#pragma clang diagnostic pop
- (UILabel* (^)(NSInteger))lq_tag {
return ^(NSInteger value) {
self.tag = value;
return self;
};
}
- (UILabel* (^)(BOOL))lq_clipsToBounds {
return ^(BOOL value) {
self.clipsToBounds = value;
return self;
};
}
- (UILabel* (^)(BOOL))lq_opaque {
return ^(BOOL value) {
self.opaque = value;
return self;
};
}
- (UILabel* (^)(BOOL))lq_hidden {
return ^(BOOL value) {
self.hidden = value;
return self;
};
}
- (UILabel* (^)(CGFloat))lq_alpha {
return ^(CGFloat value) {
self.alpha = value;
return self;
};
}
- (UILabel* (^)(UIViewContentMode))lq_contentMode {
return ^(UIViewContentMode value) {
self.contentMode = value;
return self;
};
}
@end
@implementation UIButton (chain)
- (UIButton* (^)(BOOL))lq_enabled {
return ^(BOOL value) {
self.enabled = value;
return self;
};
}
- (UIButton* (^)(BOOL))lq_selected {
return ^(BOOL value) {
self.selected = value;
return self;
};
}
- (UIButton* (^)(BOOL))lq_highlighted {
return ^(BOOL value) {
self.highlighted = value;
return self;
};
}
- (UIButton* (^)(BOOL))lq_adjustsImageWhenHighlighted {
return ^(BOOL value) {
self.adjustsImageWhenHighlighted = value;
return self;
};
}
- (UIButton* (^)(BOOL))lq_adjustsImageWhenDisabled {
return ^(BOOL value) {
self.adjustsImageWhenDisabled = value;
return self;
};
}
- (UIButton* (^)(UIControlContentVerticalAlignment))lq_contentVerticalAlignment {
return ^(UIControlContentVerticalAlignment value) {
self.contentVerticalAlignment = value;
return self;
};
}
- (UIButton* (^)(UIControlContentHorizontalAlignment))lq_contentHorizontalAlignment {
return ^(UIControlContentHorizontalAlignment value) {
self.contentHorizontalAlignment = value;
return self;
};
}
- (UIButton* (^)(UIEdgeInsets))lq_contentEdgeInsets {
return ^(UIEdgeInsets value) {
self.contentEdgeInsets = value;
return self;
};
}
- (UIButton* (^)(UIEdgeInsets))lq_titleEdgeInsets {
return ^(UIEdgeInsets value) {
self.titleEdgeInsets = value;
return self;
};
}
- (UIButton* (^)(UIEdgeInsets))lq_imageEdgeInsets {
return ^(UIEdgeInsets value) {
self.imageEdgeInsets = value;
return self;
};
}
- (UIButton* (^)(UIColor*))lq_tintColor {
return ^(UIColor* value) {
self.tintColor = value;
return self;
};
}
- (UIButton* (^)(NSString*))lq_normalTitle {
return ^(NSString* value) {
[self setTitle:value forState:UIControlStateNormal];
return self;
};
}
- (UIButton* (^)(NSString*))lq_highlightedTitle {
return ^(NSString* value) {
[self setTitle:value forState:UIControlStateHighlighted];
return self;
};
}
- (UIButton* (^)(NSString*))lq_disabledTitle {
return ^(NSString* value) {
[self setTitle:value forState:UIControlStateDisabled];
return self;
};
}
- (UIButton* (^)(NSString*))lq_selectedTitle {
return ^(NSString* value) {
[self setTitle:value forState:UIControlStateSelected];
return self;
};
}
- (UIButton* (^)(UIColor*))lq_normalTitleColor {
return ^(UIColor* value) {
[self setTitleColor:value forState:UIControlStateNormal];
return self;
};
}
- (UIButton* (^)(UIColor*))lq_highlightedTitleColor {
return ^(UIColor* value) {
[self setTitleColor:value forState:UIControlStateHighlighted];
return self;
};
}
- (UIButton* (^)(UIColor*))lq_disabledTitleColor {
return ^(UIColor* value) {
[self setTitleColor:value forState:UIControlStateDisabled];
return self;
};
}
- (UIButton* (^)(UIColor*))lq_selectedTitleColor {
return ^(UIColor* value) {
[self setTitleColor:value forState:UIControlStateSelected];
return self;
};
}
- (UIButton* (^)(UIColor*))lq_normalTitleShadowColor {
return ^(UIColor* value) {
[self setTitleShadowColor:value forState:UIControlStateNormal];
return self;
};
}
- (UIButton* (^)(UIColor*))lq_highlightedTitleShadowColor {
return ^(UIColor* value) {
[self setTitleShadowColor:value forState:UIControlStateHighlighted];
return self;
};
}
- (UIButton* (^)(UIColor*))lq_disabledTitleShadowColor {
return ^(UIColor* value) {
[self setTitleShadowColor:value forState:UIControlStateDisabled];
return self;
};
}
- (UIButton* (^)(UIColor*))lq_selectedTitleShadowColor {
return ^(UIColor* value) {
[self setTitleShadowColor:value forState:UIControlStateSelected];
return self;
};
}
- (UIButton* (^)(UIImage*))lq_normalImage {
return ^(UIImage* value) {
[self setImage:value forState:UIControlStateNormal];
return self;
};
}
- (UIButton* (^)(UIImage*))lq_highlightedImage {
return ^(UIImage* value) {
[self setImage:value forState:UIControlStateHighlighted];
return self;
};
}
- (UIButton* (^)(UIImage*))lq_disabledImage {
return ^(UIImage* value) {
[self setImage:value forState:UIControlStateDisabled];
return self;
};
}
- (UIButton* (^)(UIImage*))lq_selectedImage {
return ^(UIImage* value) {
[self setImage:value forState:UIControlStateSelected];
return self;
};
}
- (UIButton* (^)(UIImage*))lq_normalBackgroundImage {
return ^(UIImage* value) {
[self setBackgroundImage:value forState:UIControlStateNormal];
return self;
};
}
- (UIButton* (^)(UIImage*))lq_highlightedBackgroundImage {
return ^(UIImage* value) {
[self setBackgroundImage:value forState:UIControlStateHighlighted];
return self;
};
}
- (UIButton* (^)(UIImage*))lq_disabledBackgroundImage {
return ^(UIImage* value) {
[self setBackgroundImage:value forState:UIControlStateDisabled];
return self;
};
}
- (UIButton* (^)(UIImage*))lq_selectedBackgroundImage {
return ^(UIImage* value) {
[self setBackgroundImage:value forState:UIControlStateSelected];
return self;
};
}
- (UIButton* (^)(NSAttributedString*))lq_normalAttributedTitle {
return ^(NSAttributedString* value) {
[self setAttributedTitle:value forState:UIControlStateNormal];
return self;
};
}
- (UIButton* (^)(NSAttributedString*))lq_highlightedAttributedTitle {
return ^(NSAttributedString* value) {
[self setAttributedTitle:value forState:UIControlStateHighlighted];
return self;
};
}
- (UIButton* (^)(NSAttributedString*))lq_disabledAttributedTitle {
return ^(NSAttributedString* value) {
[self setAttributedTitle:value forState:UIControlStateDisabled];
return self;
};
}
- (UIButton* (^)(NSAttributedString*))lq_selectedAttributedTitle {
return ^(NSAttributedString* value) {
[self setAttributedTitle:value forState:UIControlStateSelected];
return self;
};
}
- (UIButton* (^)(UIFont*))lq_font {
return ^(UIFont* value) {
self.titleLabel.font = value;
return self;
};
}
- (UIButton* (^)(NSLineBreakMode))lq_lineBreakMode {
return ^(NSLineBreakMode value) {
self.titleLabel.lineBreakMode = value;
return self;
};
}
- (UIButton* (^)(NSInteger))lq_tag {
return ^(NSInteger value) {
self.tag = value;
return self;
};
}
- (UIButton* (^)(BOOL))lq_clipsToBounds {
return ^(BOOL value) {
self.clipsToBounds = value;
return self;
};
}
- (UIButton* (^)(BOOL))lq_opaque {
return ^(BOOL value) {
self.opaque = value;
return self;
};
}
- (UIButton* (^)(BOOL))lq_hidden {
return ^(BOOL value) {
self.hidden = value;
return self;
};
}
- (UIButton* (^)(CGFloat))lq_alpha {
return ^(CGFloat value) {
self.alpha = value;
return self;
};
}
- (UIButton* (^)(UIViewContentMode))lq_contentMode {
return ^(UIViewContentMode value) {
self.contentMode = value;
return self;
};
}
@end
@implementation UITextField (chain)
- (UITextField* (^)(NSString*))lq_text {
return ^(NSString* value) {
self.text = value;
return self;
};
}
- (UITextField* (^)(NSString*))lq_placeholder {
return ^(NSString* value) {
self.placeholder = value;
return self;
};
}
- (UITextField* (^)(NSAttributedString*))lq_attributedText {
return ^(NSAttributedString* value) {
self.attributedText = value;
return self;
};
}
- (UITextField* (^)(NSAttributedString*))lq_attributedPlaceholder {
return ^(NSAttributedString* value) {
self.attributedPlaceholder = value;
return self;
};
}
- (UITextField* (^)(UIColor*))lq_textColor {
return ^(UIColor* value) {
self.textColor = value;
return self;
};
}
- (UITextField* (^)(UIFont*))lq_font {
return ^(UIFont* value) {
self.font = value;
return self;
};
}
- (UITextField* (^)(NSTextAlignment))lq_textAlignment {
return ^(NSTextAlignment value) {
self.textAlignment = value;
return self;
};
}
- (UITextField* (^)(UITextBorderStyle))lq_borderStyle {
return ^(UITextBorderStyle value) {
self.borderStyle = value;
return self;
};
}
- (UITextField* (^)(BOOL))lq_clearsOnBeginEditing {
return ^(BOOL value) {
self.clearsOnBeginEditing = value;
return self;
};
}
- (UITextField* (^)(BOOL))lq_adjustsFontSizeToFitWidth {
return ^(BOOL value) {
self.adjustsFontSizeToFitWidth = value;
return self;
};
}
- (UITextField* (^)(CGFloat))lq_minimumFontSize {
return ^(CGFloat value) {
self.minimumFontSize = value;
return self;
};
}
- (UITextField* (^)(UIImage*))lq_background {
return ^(UIImage* value) {
self.background = value;
return self;
};
}
- (UITextField* (^)(UIImage*))lq_disabledBackground {
return ^(UIImage* value) {
self.disabledBackground = value;
return self;
};
}
- (UITextField* (^)(UIView*))lq_leftView {
return ^(UIView* value) {
self.leftView = value;
return self;
};
}
- (UITextField* (^)(UIView*))lq_rightView {
return ^(UIView* value) {
self.rightView = value;
return self;
};
}
- (UITextField* (^)(UITextFieldViewMode))lq_clearButtonMode {
return ^(UITextFieldViewMode value) {
self.clearButtonMode = value;
return self;
};
}
- (UITextField* (^)(UITextFieldViewMode))lq_leftViewMode {
return ^(UITextFieldViewMode value) {
self.leftViewMode = value;
return self;
};
}
- (UITextField* (^)(UITextFieldViewMode))lq_rightViewMode {
return ^(UITextFieldViewMode value) {
self.rightViewMode = value;
return self;
};
}
@end