源码地址:https://pan.baidu.com/s/1mi9SOGC
一,添加一个可滑动的悬浮窗我这里会介绍三种方法。
1.直接在一个控制器中,可以初始化一个视图,
// // ViewController.m // 浮动控件 // // Created by LJX on 2017/10/9. // Copyright © 2017年 LJX. All rights reserved. // #import "ViewController.h" #import "UIView+Extension.h" #import "MYButton.h" #import "AppDelegate.h" @interface ViewController () @property (nonatomic, strong) UIView *activeView; @property (nonatomic, assign) CGFloat x1; @property (nonatomic, assign) CGFloat y1; @property (nonatomic, strong) MYButton *btn; @end @implementation ViewController -(MYButton *)btn{ if (!_btn) { _btn = [[MYButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width-60, self.view.frame.size.height-60, 50, 50)]; } return _btn; } -(UIView *)activeView{ if (!_activeView) { _activeView = [[UIView alloc] initWithFrame:CGRectMake(self.view.frame.size.width-60, self.view.frame.size.height-60, 50, 50)]; _activeView.layer.cornerRadius = 25; _activeView.backgroundColor = [UIColor greenColor]; } return _activeView; } - (void)viewDidLoad { [super viewDidLoad]; [self.view addSubview:sel