Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
anjohnlv authored Sep 14, 2017
1 parent 657b5db commit f9b42a1
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# DraggableViewDemo

这份代码能够让你轻松实现可拖动的视图。

使用方法:

1、下载并导入分类UIView+Draggable。

2、对需要拖动的控件设置draggingType。

支持继承于UIView的所有控件如UIButton、UITableView、ContainerView等。
支持autolayout,autosizing。被拖动的控件会自动移除边距约束。
支持代码,也支持interface builder。

可设置类型包括:

```
/**
拖拽方式
- DraggingTypeDisabled :不能拖拽
- DraggingTypeNormal: 正常拖拽
- DraggingTypeRevert: 释放后还原
- DraggingTypePullOver: 自动靠边,只会靠左右两边
- DraggingTypeAdsorb: 靠边时自动吸附边缘,可吸附四周
*/
typedef NS_ENUM(NSUInteger, DraggingType) {
DraggingTypeDisabled,
DraggingTypeNormal,
DraggingTypeRevert,
DraggingTypePullOver,
DraggingTypeAdsorb,
};
```
可设置拖动范围
```
/**
是否可只能在subView的范围内,默认是NO。
@warning 如果NO,超出subView范围的部分无法响应拖拽。剪裁超出部分可直接使用superView.clipsToBounds=YES
*/
@property(nonatomic)BOOL draggingInBounds;
```
可主动操作View
```
/**
主动靠边并吸附
*/
-(void)adsorbingAnimated:(BOOL)animated;
/**
主动靠边
*/
-(void)pullOverAnimated:(BOOL)animated;
/**
主动还原位置
*/
-(void)revertAnimated:(BOOL)animated;
```
可监听拖动事件以实现更多自定义功能
```
-(void)draggingDidBegan:(UIView *)view;
-(void)draggingDidChanged:(UIView *)view;
-(void)draggingDidEnded:(UIView *)view;
```

如果有什么不对的地方欢迎斧正。

0 comments on commit f9b42a1

Please sign in to comment.