美文网首页iOS常用
iOS 全屏悬浮按钮,可以拖动吸附到边缘,几行代码即可实现

iOS 全屏悬浮按钮,可以拖动吸附到边缘,几行代码即可实现

作者: Kpengs | 来源:发表于2021-07-07 10:26 被阅读0次

    Demo含OC和Swift两种版本,便于不同项目使用

    下载地址

    https://github.com/PZXforXcode/PZXFreeMoveButton

    查看效果

    悬浮按钮.gif

    使用方法

    将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)
    

    下载地址

    https://github.com/PZXforXcode/PZXFreeMoveButton

    相关文章

      网友评论

        本文标题:iOS 全屏悬浮按钮,可以拖动吸附到边缘,几行代码即可实现

        本文链接:https://www.haomeiwen.com/subject/roloultx.html