Demo含OC和Swift两种版本,便于不同项目使用
下载地址
https://github.com/PZXforXcode/PZXFreeMoveButton
查看效果

使用方法
将PZXFreeMoveButtonControl 文件夹放入你的代码中
在需要的页面 #import "PZXFreeMoveButtonControl.h"
具体代码
PZXFreeMoveButton *button = [[PZXFreeMoveButton alloc]initWithFrame:CGRectMake(0,200, 60, 60)];
button.backgroundColor = [UIColor cyanColor];
// button
button.titleLabel.text = @"点击";
[button setActionBlock:^{
NSLog(@"tap");
}];
[self.view addSubview:button];
//------Swift使用方法--------
let freeButton = PZXFreeMoveButton.init(frame: CGRect.init(x: 0, y: 200, width: 60, height: 60))
freeButton.backgroundColor = .cyan
freeButton.titleLabel.text = "点击"
freeButton.setActionBlock {
print("tap")
}
self.view.addSubview(freeButton)
网友评论