Skip to content

Commit 65d62e4

Browse files
committed
可以拖曳,任你拽
1 parent 1448d74 commit 65d62e4

File tree

11 files changed

+406
-16
lines changed

11 files changed

+406
-16
lines changed

.DS_Store

0 Bytes
Binary file not shown.

PlayerDemo.xcodeproj/project.pbxproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
701570961E067CC700632595 /* WMDragView.m in Sources */ = {isa = PBXBuildFile; fileRef = 701570951E067CC700632595 /* WMDragView.m */; };
1011
BF1624601DF50011006209D1 /* DataManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BF1623B81DF50011006209D1 /* DataManager.m */; };
1112
BF1624611DF50011006209D1 /* SidModel.m in Sources */ = {isa = PBXBuildFile; fileRef = BF1623BA1DF50011006209D1 /* SidModel.m */; };
1213
BF1624621DF50011006209D1 /* VideoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = BF1623BC1DF50011006209D1 /* VideoModel.m */; };
@@ -94,6 +95,8 @@
9495

9596
/* Begin PBXFileReference section */
9697
405F2043D18D2B06CC91D75F /* libPods-PlayerDemo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-PlayerDemo.a"; sourceTree = BUILT_PRODUCTS_DIR; };
98+
701570941E067CC700632595 /* WMDragView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMDragView.h; sourceTree = "<group>"; };
99+
701570951E067CC700632595 /* WMDragView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WMDragView.m; sourceTree = "<group>"; };
97100
A41F0B6E980617F314AD7227 /* Pods-PlayerDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PlayerDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo.release.xcconfig"; sourceTree = "<group>"; };
98101
AD4E1C1A77CA0A18F1DFB6AE /* Pods-PlayerDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PlayerDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PlayerDemo/Pods-PlayerDemo.debug.xcconfig"; sourceTree = "<group>"; };
99102
BF1623B71DF50011006209D1 /* DataManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataManager.h; sourceTree = "<group>"; };
@@ -246,6 +249,15 @@
246249
/* End PBXFrameworksBuildPhase section */
247250

248251
/* Begin PBXGroup section */
252+
701570791E06384A00632595 /* WMDragView */ = {
253+
isa = PBXGroup;
254+
children = (
255+
701570941E067CC700632595 /* WMDragView.h */,
256+
701570951E067CC700632595 /* WMDragView.m */,
257+
);
258+
path = WMDragView;
259+
sourceTree = "<group>";
260+
};
249261
8AAEEC1312C0C3531902D027 /* Pods */ = {
250262
isa = PBXGroup;
251263
children = (
@@ -304,6 +316,7 @@
304316
BF1623DA1DF50011006209D1 /* ThirdLib */ = {
305317
isa = PBXGroup;
306318
children = (
319+
701570791E06384A00632595 /* WMDragView */,
307320
BF1623F31DF50011006209D1 /* MBprogressHUD */,
308321
BF1623F91DF50011006209D1 /* MJRefresh */,
309322
BF1624261DF50011006209D1 /* ScreenShotBack */,
@@ -742,6 +755,7 @@
742755
BF1624AF1DF50011006209D1 /* SinaNewsViewController.m in Sources */,
743756
BF1624981DF50011006209D1 /* UIView+MJExtension.m in Sources */,
744757
BF16249C1DF50011006209D1 /* SDWebImageCompat.m in Sources */,
758+
701570961E067CC700632595 /* WMDragView.m in Sources */,
745759
BF1624A41DF50011006209D1 /* UIImage+MultiFormat.m in Sources */,
746760
BF1624C71DF50182006209D1 /* WMPlayer.m in Sources */,
747761
BF1624931DF50011006209D1 /* MJRefreshStateHeader.m in Sources */,

PlayerDemo/.DS_Store

0 Bytes
Binary file not shown.

PlayerDemo/ThirdLib/.DS_Store

2 KB
Binary file not shown.
6 KB
Binary file not shown.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//
2+
// WMDragView.h
3+
// DragButtonDemo
4+
//
5+
// Created by zhengwenming on 2016/12/16.
6+
//
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
12+
// 拖曳view的方向
13+
typedef NS_ENUM(NSInteger, WMDragDirection) {
14+
WMDragDirectionAny, /**< 任意方向 */
15+
WMDragDirectionHorizontal, /**< 水平方向 */
16+
WMDragDirectionVertical, /**< 垂直方向 */
17+
};
18+
19+
@interface WMDragView : UIView<UIGestureRecognizerDelegate>
20+
21+
/**
22+
是不是能拖曳,
23+
YES,能拖曳
24+
NO,不能拖曳
25+
*/
26+
@property (nonatomic,assign) BOOL dragEnable;
27+
28+
/**
29+
活动范围,默认为父视图的frame范围内(因为拖出父视图后无法点击,也没意义)
30+
如果设置了,则会在给定的范围内活动
31+
如果没设置,则会在父视图范围内活动
32+
注意:设置的frame不要大于父视图范围
33+
注意:设置的frame为0,0,0,0表示活动的范围为默认的父视图frame,如果想要不能活动,请设置dragEnable这个属性为NO
34+
*/
35+
@property (nonatomic,assign) CGRect freeRect;
36+
37+
/**
38+
拖曳的方向,默认为any,任意方向
39+
*/
40+
@property (nonatomic,assign) WMDragDirection dragDirection;
41+
42+
/**
43+
内部的一个UIImageView,采用懒加载的方式,开发者用的时候才会创建,不用就为nil
44+
开发者也可以自定义控件添加到本view中
45+
注意:最好不要同时使用内部的imageView和button
46+
*/
47+
@property (nonatomic,strong) UIImageView *imageView;
48+
49+
/**
50+
内部的一个UIButton,采用懒加载的方式,开发者用的时候才会创建,不用就为nil
51+
开发者也可以自定义控件添加到本view中
52+
注意:最好不要同时使用内部的imageView和button
53+
*/
54+
@property (nonatomic,strong) UIButton *button;
55+
56+
/**
57+
内容view,命名为contentViewForDrag,因为很多第三方的库继承UIView,里面同样有contentView这个属性
58+
防止冲突,这里特别命名为contentViewForDrag
59+
*/
60+
@property (nonatomic,strong) UIView *contentViewForDrag;
61+
62+
/**
63+
点击的回调block
64+
*/
65+
@property (nonatomic,copy) void(^ClickDragViewBlock)(WMDragView *dragView);
66+
67+
/**
68+
开始拖动的回调block
69+
*/
70+
@property (nonatomic,copy) void(^BeginDragBlock)(WMDragView *dragView);
71+
/**
72+
拖动中的回调block
73+
*/
74+
@property (nonatomic,copy) void(^DuringDragBlock)(WMDragView *dragView);
75+
/**
76+
结束拖动的回调block
77+
*/
78+
@property (nonatomic,copy) void(^EndDragBlock)(WMDragView *dragView);
79+
80+
/**
81+
是不是保持在边界,默认为NO,没有黏贴边界效果
82+
isKeepBounds = YES,它将自动黏贴边界,而且是最近的边界
83+
isKeepBounds = NO, 它将不会黏贴在边界,它是free(自由)状态,跟随手指到任意位置,但是也不可以拖出规定的范围
84+
*/
85+
@property (nonatomic,assign) BOOL isKeepBounds;
86+
87+
@end
88+
89+

0 commit comments

Comments
 (0)