-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathWMDragView.h
More file actions
77 lines (68 loc) · 2.28 KB
/
WMDragView.h
File metadata and controls
77 lines (68 loc) · 2.28 KB
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
//
// WMDragView.h
// WMDragView
//
// Created by zhengwenming on 2016/12/16.
//
//
#import <UIKit/UIKit.h>
// 拖曳view的方向
typedef NS_ENUM(NSInteger, WMDragDirection) {
WMDragDirectionAny, /**< 任意方向 */
WMDragDirectionHorizontal, /**< 水平方向 */
WMDragDirectionVertical, /**< 垂直方向 */
};
@interface WMDragView : UIView
/**
是不是能拖曳,默认为YES
YES,能拖曳
NO,不能拖曳
*/
@property (nonatomic,assign) BOOL dragEnable;
/**
活动范围,默认为父视图的frame范围内(因为拖出父视图后无法点击,也没意义)
如果设置了,则会在给定的范围内活动
如果没设置,则会在父视图范围内活动
注意:设置的frame不要大于父视图范围
注意:设置的frame为0,0,0,0表示活动的范围为默认的父视图frame,如果想要不能活动,请设置dragEnable这个属性为NO
*/
@property (nonatomic,assign) CGRect freeRect;
/**
拖曳的方向,默认为any,任意方向
*/
@property (nonatomic,assign) WMDragDirection dragDirection;
/**
contentView内部懒加载的一个UIImageView
开发者也可以自定义控件添加到本view中
注意:最好不要同时使用内部的imageView和button
*/
@property (nonatomic,strong) UIImageView *imageView;
/**
contentView内部懒加载的一个UIButton
开发者也可以自定义控件添加到本view中
注意:最好不要同时使用内部的imageView和button
*/
@property (nonatomic,strong) UIButton *button;
/**
是不是总保持在父视图边界,默认为NO,没有黏贴边界效果
isKeepBounds = YES,它将自动黏贴边界,而且是最近的边界
isKeepBounds = NO, 它将不会黏贴在边界,它是free(自由)状态,跟随手指到任意位置,但是也不可以拖出给定的范围frame
*/
@property (nonatomic,assign) BOOL isKeepBounds;
/**
点击的回调block
*/
@property (nonatomic,copy) void(^clickDragViewBlock)(WMDragView *dragView);
/**
开始拖动的回调block
*/
@property (nonatomic,copy) void(^beginDragBlock)(WMDragView *dragView);
/**
拖动中的回调block
*/
@property (nonatomic,copy) void(^duringDragBlock)(WMDragView *dragView);
/**
结束拖动的回调block
*/
@property (nonatomic,copy) void(^endDragBlock)(WMDragView *dragView);
@end