Git Product home page Git Product logo

misfloatingball's Introduction

MISFloatingBall

GitHub issues

简介

一个轻量级的简单到爆炸的悬浮球(详细使用可参见Demo)

功能

  • 全局和指定View生效的悬浮球类型
  • 自动靠边
  • 自动靠边并缩进,自定义缩进状态
  • 设置图片内容
  • 设置文字内容
  • 设置自定义内容
  • 点击悬浮球回调
  • 扩展视图,点击弹出(见游戏App中的悬浮球)
  • 旋转适配

使用说明

  • 初始化

      MISFloatingBall *floatingBall = [[MISFloatingBall alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];// 全局作用
      MISFloatingBall *floatingBall = [[MISFloatingBall alloc] initWithFrame:CGRectMake(100, 100, 100, 100) inSpecifiedView:self.view];// 指定View生效
    
  • 显示和隐藏

      [floatingBall visible];			// 显示
      [floatingBall disVisible];		// 隐藏
    
  • 生成后是否自动靠边

      floatingBall.autoCloseEdge = YES;
    
  • 更改悬浮球的靠边策略(默认是上下左右都可以靠,默认时候的逻辑是和系统的assistiveTouch相同,接触到底部或顶部一定距离之后靠近上下边缘)

      floatingBall.edgePolicy = MISFloatingBallEdgePolicyLeftRight;
    
  • 设置悬浮球显示的内容(内部自动居中)

      // 设置图片 
      [floatingBall setContent:[UIImage imageNamed:@"apple"] contentType:MISFloatingBallContentTypeImage];
      
      // 设置文字
      [floatingBall setContent:@"我是文字" contentType:MISFloatingBallContentTypeText];
    
  • 如果想要添加一个自定义的视图到悬浮球中

      // 设置一个自定义的视图
      MISCustomButton *button = [[MISCustomButton alloc] initWithFrame:CGRectMake(0, 0, 80, 80)];
      button.titleLabel.textAlignment = NSTextAlignmentCenter;
      button.imageSize = CGSizeMake(44, 44);
      button.titleLabel.font = [UIFont systemFontOfSize:16.0f];
      button.backgroundColor = [UIColor redColor];
    
      [button setImage:[UIImage imageNamed:@"apple"] forState:UIControlStateNormal];
      [button setTitle:@"一个图片" forState:UIControlStateNormal];
    
      // 设置自定义视图
      [floatingBall setContent:button contentType:MISFloatingBallContentTypeCustomView];
    
  • 当在autoCloseEdge为YES的时候,设置一段间隔后自动缩进边缘

      // 缩进的主要参数
      UIKIT_STATIC_INLINE MISEdgeRetractConfig MISEdgeOffsetConfigMake(CGPoint edgeRetractOffset, CGFloat edgeRetractAlpha) {
         MISEdgeRetractConfig config = {edgeRetractOffset, edgeRetractAlpha};
         return config;
      }
      
      // 设置缩进
      // 缩进时候如果靠的是左右边缘则x缩进20,如果上下则y缩进30,并且缩进后悬浮球透明度渐变为0.7f
      [floatingBall autoEdgeRetractDuration:3.0f edgeRetractConfigHander:^MISEdgeRetractConfig{
      	return MISEdgeOffsetConfigMake(CGPointMake(20, 30), 0.7f);
      }];
    
  • 悬浮球的点击

      __block typeof(floating) blockBall = floatingBall;
      [floating setClickHander:^{
      	  // 主要可以实现悬浮球点击之后的事件处理
           [blockBall disVisible];
      }];
    

系统要求

最低支持 iOS 7.0Xcode 7.0

issue

如果存在bug或有重大问题欢迎提给我,希望可以一起共同学习进步

misfloatingball's People

Contributors

wolfcolony avatar

Watchers

James Cloos avatar iOS Developer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.