cdts/xdts-ios 3/TreeHole/Code/Gategory/UIViewAdditions/UIViewAdditions.h

134 lines
3.8 KiB
C
Raw Normal View History

2023-07-27 09:20:00 +08:00
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, GradientColorType) {
GradientColorTypeFromTopToBottom = 1, //从上到下
GradientColorTypeFromLeftToRight, //从做到右
GradientColorTypeFromLeftTopToRightBottom, //从上到下
GradientColorTypeFromLeftBottomToRightTop //从上到下
};
extern CGRect fixRect(CGFloat x, CGFloat y, CGFloat width, CGFloat height);
extern CGPoint fixPoint(CGFloat x, CGFloat y);
extern CGSize fixSize(CGFloat width,CGFloat height);
@interface UIView (TTCategory)
@property(nonatomic) CGFloat left;
@property(nonatomic) CGFloat top;
@property(nonatomic) CGFloat right;
@property(nonatomic) CGFloat bottom;
@property(nonatomic) CGFloat width;
@property(nonatomic) CGFloat height;
@property(nonatomic) CGFloat centerX;
@property(nonatomic) CGFloat centerY;
@property(nonatomic,readonly) CGFloat screenX;
@property(nonatomic,readonly) CGFloat screenY;
@property(nonatomic,readonly) CGFloat screenViewX;
@property(nonatomic,readonly) CGFloat screenViewY;
@property(nonatomic,readonly) CGRect screenFrame;
@property (nonatomic, assign) CGFloat x;
@property (nonatomic, assign) CGFloat y;
@property (nonatomic, assign) CGSize size;
@property (nonatomic, assign) CGPoint origin;
@property (nonatomic, assign, readonly) CGFloat bottomFromSuperView;
//在父控件居中对齐
- (void)mt_AlignCenterXToSuperView;
- (void)mt_AlignCenterYToSuperView;
- (void)mt_AlignCenterToSuperView;
//@property(nonatomic,readonly) CGFloat orientationWidth;
//@property(nonatomic,readonly) CGFloat orientationHeight;
- (UIScrollView*)findFirstScrollView;
- (UIView*)firstViewOfClass:(Class)cls;
- (UIView*)firstParentOfClass:(Class)cls;
- (UIView*)findChildWithDescendant:(UIView*)descendant;
/**
* Removes all subviews.
*/
- (void)removeSubviews;
/**
* WARNING: This depends on undocumented APIs and may be fragile. For testing only.
*/
- (void)simulateTapAtPoint:(CGPoint)location;
- (CGPoint)offsetFromView:(UIView*)otherView;
- (void)viewAddTopLine;
- (void)viewAddTopLine:(CGFloat)aOffsetx;
- (UIView *)viewAddMiddleLine:(CGFloat)aOffsetx;
- (UIView *)getViewLine:(CGRect)aRect;
// 在view添加分割线
- (UIView *)addBottomSepetatorLineOffsetX:(CGFloat)offsetX;
// 虚线
- (void)addBottomDottedLine;
//- (void)viewaddCircleLine;
//- (void)viewAddBottomLine;
/*
* 2.UIView
*
* @param target
* @param action
*/
- (UITapGestureRecognizer *)addTapGestureTarget:(id)target
action:(SEL)action;
- (void)addTapWithAction:(void(^)(void))tapAction;
// 渐变背景
- (void)setBackgroundGradientColorWithBeginColorHex:(int)beginColorHex endColorHex:(int)endColorHex gradientType:(GradientColorType)gradientType;
//- (UIView *)tableviewFootView:(CGRect)aRect;
- (void)makeCenterToastActivity;
//弹出一个类似present效果的窗口
- (void)presentView:(UIView*)view animated:(BOOL)animated complete:(void(^)(void)) complete;
//获取一个view上正在被present的view
- (UIView *)presentedView;
- (void)dismissPresentedView:(BOOL)animated complete:(void(^)(void)) complete;
//这个是被present的窗口本身的方法
//如果自己是被present出来的消失掉
- (void)hideSelf:(BOOL)animated complete:(void(^)(void)) complete;
// 设置圆角
- (void)setCorners:(UIRectCorner)corners radius:(CGFloat)radius;
- (void)addLongPressWithAction:(void (^)(void))longPressAction;
+ (UIView *)lineViewWithWidth:(CGFloat)width;
- (void)clearBackgroudColorForClassNames:(NSArray<NSString *> *)classNames;
@end
typedef void(^TouchUpInsideActionBlock)(UIButton * _Nullable button);
@interface UIButton(Addition)
- (void)addTouchUpInsideWithAction:(TouchUpInsideActionBlock _Nullable )action;
- (void)setDisable:(BOOL)disable;
@end