出现在您的视图中的可拖动按钮。
直到版本 1.0 之前,RCDraggableButton 都不适用于生产使用。
在您的终端中,
cd [projdir]/RCDraggableButtonDemo
pod install
饮过一杯茶后,您应该能够在 Xcode5 中打开 RCDraggableButtonDemo.xcworkspace
来构建和运行 RCDraggableButtonDemo
项目。
open RCDraggableButtonDemo.xcworkspace
您只需将 Src
文件拖到您的项目中,并将 #include "RCDraggableButton.h"
添加到将要使用它的类的顶部即可。
在您的 AppViewController 的 - (void)viewDidLoad
中创建 draggableButton 并将其添加到 keyWindow 或自定义视图。
// Set view as nil, means add button to keyWindow
RCDraggableButton *draggableButton = [[RCDraggableButton alloc] initInView:nil WithFrame:CGRectMake(120, 120, 60, 60)];
// Or add button to customView that you set in -init method
UIView *customView = ...;
[self.view addSubview:customView];
RCDraggableButton *avatar = [[RCDraggableButton alloc] initInView:customView WithFrame:CGRectMake(120, 120, 60, 60)];
您还可以手动使用它
RCDraggableButton *draggableButton = [[RCDraggableButton alloc] initWithFrame:CGRectMake(0, 100, 60, 60)];
[self.view addSubview:draggableButton];
有关更多用法示例,请参阅 RCDraggableButtonDemo
中的演示项目,或 Src
中的源文件。
RCDraggableButton 可在 MIT 许可下使用。有关更多信息,请参阅 LICENSE 文件。