View

简单动画

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
29
30
31
32
33
34
#pragma mark - build in


/**
build in 动画

@param scale 缩放比例
@param duration 持续时间
@param completion 完成后执行
*/
- (void)ax_animatedScaleIn:(CGFloat)scale duration:(NSTimeInterval)duration completion:(void (^)(BOOL finished))completion;

#pragma mark - action

/**
动画

@param scale 缩放比例
@param duration 持续时间
@param completion 完成后执行
*/
- (void)ax_animatedScale:(CGFloat)scale duration:(NSTimeInterval)duration completion:(void (^)(BOOL finished))completion;


#pragma mark - build out

/**
build out 动画

@param scale 缩放比例
@param duration 持续时间
@param completion 完成后执行
*/
- (void)ax_animatedScaleOut:(CGFloat)scale duration:(NSTimeInterval)duration completion:(void (^)(BOOL finished))completion;

创建一个指定高的view

1
2
3
4
5
6
7
8
/**
创建一个指定高的view

@param height 高度

@return view
*/
CG_EXTERN UIView *UIViewWithHeight(CGFloat height);

读取xib

1
2
3
4
5
6
7
/**
从xib加载view

@param name xib名
@return view
*/
CG_EXTERN __kindof UIView *UIViewFromNibNamed(NSString *name);

对view的layer进行若干操作

1
2
3
4
5
6
/**
对view的layer进行若干操作

@param layer layer
*/
- (void)ax_layer:(void (^)(CALayer *layer))layer;

获取view所在的控制器

1
2
3
4
5
6
/**
当前view所在的控制器controller

@return 控制器controller
*/
- (nullable UIViewController *)controller;

Subview

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
移除所有子视图

@param subClass 指定范围(只移除属于哪个类的子视图,传入nil时移除所有子视图)
*/
- (void)ax_removeAllSubviews:(nullable Class)subClass;


/**
让每个子视图执行一段代码

@param subClass 指定范围(属于哪个类的子视图,传入nil时代表所有子视图)
@param action 子视图所执行的代码块
*/
- (void)ax_eachSubview:(nullable Class)subClass action:(void (^)(__kindof UIView *subview))action;


/**
让每个UILabel执行一段代码

@param action 要执行的代码
*/
- (void)ax_eachLabelInvokeAction:(void (^)(__kindof UILabel *label))action;

/**
让每个UITextField执行一段代码

@param action 要执行的代码
*/
- (void)ax_eachTextFieldInvokeAction:(void (^)(__kindof UITextField *textField))action;

/**
让每个UITextView执行一段代码

@param action 要执行的代码
*/
- (void)ax_eachTextViewInvokeAction:(void (^)(__kindof UITextView *textView))action;

/**
让每个UIButton执行一段代码

@param action 要执行的代码
*/
- (void)ax_eachButtonInvokeAction:(void (^)(__kindof UIButton *button))action;

/**
让每个UIImageView执行一段代码

@param action 要执行的代码
*/
- (void)ax_eachImageViewInvokeAction:(void (^)(__kindof UIImageView *imageView))action;



/**
让每个tag在指定范围的子视图执行一段代码

@param tagRange 指定tag取值范围
@param action 要执行的代码
*/
- (void)ax_eachSubviewWithTagsInRange:(AXIntegerRange)tagRange action:(void (^)(__kindof UIView *subview))action;

/**
让每个tag等于某个值的子视图执行一段代码

@param tag 指定tag值
@param action 要执行的代码
*/
- (void)ax_eachSubviewWithTag:(NSInteger)tag action:(void (^)(__kindof UIView *subview))action;

frame

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
29
30
31
32
#pragma mark - property
// frame.origin
@property (nonatomic, readwrite, assign) CGPoint origin;
// frame.size
@property (nonatomic, readwrite, assign) CGSize size;
// frame.size.width
@property (nonatomic, readwrite, assign) CGFloat width;
// frame.size.height
@property (nonatomic, readwrite, assign) CGFloat height;
// frame.origin.x
@property (nonatomic, readwrite, assign) CGFloat left;
// frame.origin.x + frame.size.width
@property (nonatomic, readwrite, assign) CGFloat right;
// frame.origin.y
@property (nonatomic, readwrite, assign) CGFloat top;
// frame.origin.y + frame.size.height
@property (nonatomic, readwrite, assign) CGFloat bottom;

#pragma mark frame center
// frame.origin.x + 0.5 * frame.size.width
@property (nonatomic, readwrite, assign) CGFloat centerX;
// frame.origin.y + 0.5 * frame.size.height
@property (nonatomic, readwrite, assign) CGFloat centerY;


#pragma mark bounds center
// bounds.center
@property (nonatomic, readonly, assign) CGPoint boundsCenter;
// 0.5 * frame.size.width
@property (nonatomic, readonly, assign) CGFloat boundsCenterX;
// 0.5 * frame.size.height
@property (nonatomic, readonly, assign) CGFloat boundsCenterY;

手势

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
处理tap手势

@param handler 处理手势的block
*/
- (void)ax_addTapGestureHandler:(void (^)(UITapGestureRecognizer *sender))handler;

/**
添加一个tap手势,并处理

@param tap tap
@param handler 处理手势的block
*/
- (void)ax_addTapGesture:(nullable void (^)(UITapGestureRecognizer *sender))tap handler:(void (^)(UITapGestureRecognizer *sender))handler;

/**
添加一个tap手势,并处理,附加动画效果

@param tap tap
@param handler 处理手势的block
@param scale 动画比例
@param duration 持续时间
*/
- (void)ax_addTapGesture:(nullable void (^)(UITapGestureRecognizer *sender))tap handler:(void (^)(UITapGestureRecognizer *sender))handler animatedScale:(CGFloat)scale duration:(NSTimeInterval)duration;

/**
添加一个双击手势,并处理

@param doubleTap double tap
@param duration 双击间隔时间
@param handler 处理手势的block
*/
- (void)ax_addDoubleTapGesture:(nullable void (^)(UITapGestureRecognizer *sender))doubleTap duration:(NSTimeInterval)duration handler:(void (^)(UITapGestureRecognizer *sender))handler;

/**
添加一个长按手势,并处理

@param longPress 长按手势
@param handler 处理手势的block
*/
- (void)ax_addLongPressGesture:(nullable void (^)(UILongPressGestureRecognizer *sender))longPress handler:(void (^)(UILongPressGestureRecognizer *sender))handler;

/**
添加一个轻扫手势,并处理

@param swipe 轻扫
@param handler 处理手势的block
*/
- (void)ax_addSwipeGesture:(nullable void (^)(UISwipeGestureRecognizer *sender))swipe handler:(void (^)(UISwipeGestureRecognizer *sender))handler;

/**
添加一个滑动手势,并处理

@param pan 滑动
@param handler 处理手势的block
*/
- (void)ax_addPanGesture:(nullable void (^)(UIPanGestureRecognizer *sender))pan handler:(void (^)(UIPanGestureRecognizer *sender))handler;

/**
添加一个屏幕边缘滑动手势,并处理

@param screenEdgePan 屏幕边缘滑动
@param handler 处理手势的block
*/
- (void)ax_addScreenEdgePanGesture:(nullable void (^)(UIScreenEdgePanGestureRecognizer *sender))screenEdgePan handler:(void (^)(UIScreenEdgePanGestureRecognizer *sender))handler;

/**
添加一个双指缩放手势,并处理

@param pinch 双指缩放手势
@param handler 处理手势的block

sender.view.transform = CGAffineTransformScale(sender.view.transform, sender.scale, sender.scale);
sender.scale = 1;
*/
- (void)ax_addPinchGesture:(nullable void (^)(UIPinchGestureRecognizer *sender))pinch handler:(void (^)(UIPinchGestureRecognizer *sender))handler;

/**
添加一个双指旋转手势,并处理

@param rotation 双指旋转手势
@param handler 处理手势的block

sender.view.transform = CGAffineTransformRotate(sender.view.transform, sender.rotation);
sender.rotation = 0;
*/
- (void)ax_addRotationGesture:(nullable void (^)(UIRotationGestureRecognizer *sender))rotation handler:(void (^)(UIRotationGestureRecognizer *sender))handler;



评论