Skip to content

venn0126/SNAugusPopView

Repository files navigation

SNAugusPopView

CI Status Version License Platform

Features

  • High performance: The library's dependencies all use system libraries and files , only a instance global.
  • Automatic layout: The text label can be automatically layout depend to single or not.
  • The alpha: Set the popView alpha is no effect text alpha.
  • High custom: You can set any property that you want to.
  • Lightweight:The library contains only 2 files,all file code total 800+ lines.
  • Docs and unit test:100% docs coverage, 99.2% code coverage.

Example

Example0

self.allPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(50, 700, 0, 0) text:@"请阅读并勾选以下协议勾选以下协议All" direction:SNAugusPopViewDirectionBottom singleLine:YES closeButtonName:@"close" leftImageName:@"left" gradient:YES];
              
// self.allPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(50, 750, 0, 0) text:@"请阅读并勾选以下协议勾选以下协议发发现新的炼金珠女呗冲啊擦法All" direction:SNAugusPopViewDirectionBottom singleLine:NO closeButtonName:@"close" leftImageName:@"left" gradient:YES];
                
  [self.view addSubview:self.allPopView];


  self.allPopView.textFont = [UIFont systemFontOfSize:16];
  self.allPopView.gradientColors = @[(id)(UIColor.orangeColor.CGColor),(id)UIColor.redColor.CGColor];
  self.allPopView.gradientStartPoint = CGPointMake(1.0, 0.5);
  self.allPopView.gradientEndPoint = CGPointMake(0.0, 0.5);
  self.allPopView.gradientLocations = @[@0.5,@1.0];

  self.allPopView.closeButtonBackgroundColor = UIColor.blackColor;
  self.allPopView.leftImageBackgroundColor = UIColor.yellowColor;

  self.leftImagePopView.leftImageWidth = 30;
  self.leftImagePopView.leftImageHeight = 15;
  self.leftImagePopView.leftImageLabelPadding = 20;
  [self.allPopView show];

Example1

self.mulLinesPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(30, 250, 0, 0) text:@"袅袅炊烟,小小村落,路上一道辙,你用你那母亲的脉搏和我诉说,我的祖国和我像海和浪花一朵MulLines" direction:SNAugusPopViewDirectionBottom singleLine:NO gradient:NO];
[self.view addSubview:self.mulLinesPopView];

self.mulLinesPopView.mulLineWidth = 100.0;
self.mulLinesPopView.arrowVerticalPadding = 30.0;
self.mulLinesPopView.textAlignment = NSTextAlignmentLeft;
self.mulLinesPopView.backgroundColor = UIColor.yellowColor;
self.mulLinesPopView.borderWidth = 5.0;
self.mulLinesPopView.borderColor = UIColor.greenColor;
// 设置mulLinesPopView展示2.5秒之后自动消失
[self.mulLinesPopView showWithDismissDelay:2.5];

Example2

self.topPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(160, self.testView.frame.origin.y + 60, 0, 0) text:@"请阅读并勾选以下协议Top" direction:SNAugusPopViewDirectionTop gradient:NO];
[self.view addSubview:self.topPopView];
self.topPopView.delegate = self;
self.topPopView.textFont = [UIFont systemFontOfSize:13];
self.topPopView.arrowHorizontalPadding = 80;
self.topPopView.textColor = UIColor.blueColor;
// 设置topPopView展示3秒之后消失,完成之后不需要进行回调操作
[self.topPopView showWithDismissDelay:3 completion:nil];

Example3

self.bottomPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(100+60, 100-20, 0, 0) text:@"请阅读并勾选以下协议Bottom" direction:SNAugusPopViewDirectionBottom gradient:YES];
self.bottomPopView.delegate = self;
[self.view addSubview:self.bottomPopView];

self.bottomPopView.arrowHorizontalPadding = 80;
self.bottomPopView.textFont = [UIFont systemFontOfSize:16];
self.bottomPopView.gradientColors = @[(id)(UIColor.orangeColor.CGColor),(id)UIColor.redColor.CGColor];
self.bottomPopView.gradientStartPoint = CGPointMake(1.0, 0.5);
self.bottomPopView.gradientEndPoint = CGPointMake(0.0, 0.5);
self.bottomPopView.gradientLocations = @[@0.5,@1.0];
// 设置bottomPopView3.5秒之后消失,完成之后并打印日志
[self.bottomPopView showWithDismissDelay:3.5 completion:^(BOOL finished) {
     NSLog(@"bottom popview dismiss");
}];

Example4

self.leftPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(230, 100+25, 0, 0) text:@"请阅读并勾选以下协议Left" direction:SNAugusPopViewDirectionLeft gradient:NO];
self.leftPopView.delegate = self;
[self.view addSubview:self.leftPopView];

self.leftPopView.textFont = [UIFont systemFontOfSize:10];
self.leftPopView.arrowVerticalPadding = 5.0;
self.leftPopView.aBackgroundRed = 0/255.0;
self.leftPopView.aBackgroundGreen = 191/255.0;
self.leftPopView.aBackgroundBlue = 255/255.0;

[self.leftPopView show];

Example5

self.rightPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(160, 100+25, 0, 0) text:@"请阅读并勾选以下协议Right" direction:SNAugusPopViewDirectionRight gradient:NO];
[self.view addSubview:self.rightPopView];
self.rightPopView.delegate = self;
self.rightPopView.textFont = [UIFont systemFontOfSize:10];
self.rightPopView.arrowVerticalPadding = 5;
self.rightPopView.textColor = UIColor.redColor;

[self.rightPopView show];

Example6

self.closePopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(50, 480, 0, 0) text:@"请阅读并勾选以下协议SingleClose" direction:SNAugusPopViewDirectionBottom singleLine:YES closeButtonName:@"Close" gradient:NO];
[self.view addSubview:self.closePopView];
[self.closePopView show];

Example7

self.leftImagePopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(50, 580, 0, 0) text:@"请阅读并勾选以下协议LeftImage" direction:SNAugusPopViewDirectionBottom singleLine:YES leftImageName:@"left" gradient:NO];
[self.view addSubview:self.leftImagePopView];

self.leftImagePopView.leftImageWidth = 30;
self.leftImagePopView.leftImageHeight = 15;

[self.leftImagePopView show];

Example8

UILabel *testLabel = [[UILabel alloc] init];
testLabel.frame = CGRectMake(0, 0, 180, 40);
testLabel.text = @"This is a custom view example.This is a custom view example.This is a custom view example.";
testLabel.numberOfLines = 0;
testLabel.font = [UIFont systemFontOfSize:12];
testLabel.textColor = UIColor.whiteColor;

self.customViewPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(200, 280, 0, 0) customView:testLabel direction:SNAugusPopViewDirectionBottom gradient:NO];
self.customViewPopView.arrowHorizontalPadding = 50; 
// Custom use labelHorizontalPadding to set padding to popView's left and right margins.
self.customViewPopView.labelHorizontalPadding = 20;
// Custom use labelVerticalPadding to set padding to popView's top and bottom margins.
self.customViewPopView.labelVerticalPadding = 15;
self.customViewPopView.arrowWidth = 20;
self.customViewPopView.arrowHeight = 12;
[self.view addSubview:self.customViewPopView];

[self.customViewPopView show];

Requirements

SNAugusPopView works on iOS 9.0+. It depends on the following Apple Frameworks, which should already be include with most Xcode Templates:

  • Foundation.framework
  • UIKit.framewrok
  • objc/runtime.h

Installation

Static Library

You can also add SNAugusPopView as a static library to your project or workspace.

  • Download the latest code version or add repository as a git submodule to your git-tracked project.
  • Open your project in Xcode, then drag and drop SNAugusPopView.xcodeproj onto your project or workspace (use the "Product Navigator view").
  • Select your target and go to the Build phases tab. In the Link Binary With Libraries section select the add button. On the sheet find and add SNAugusPopView.framework. You might also need to add SNAugusPopView to the Target Dependencies list.
  • Include SNAugusPopView wherever you need it with #import <SNAugusPopView/SNAugusPopView.h>.

Cocoapods

  • Add a pod entry for SNAugusPopView to your Podfile pod 'SNAugusPopView', '~> 0.1.0'
  • Install the pod(s) by running pod install
  • Include SNAugusPopView wherever you need it with #import <SNAugusPopView.h>

Source files

Alternatively you can directly add the SNAugusPopView.h and SNAugusPopView.m source files to your project.

  • Download the latest code version or add repository as a git submodule to your git-tracked project.
  • Open your project in Xcode, then drag and drop SNAugusPopView.h and SNAugusPopView.m onto your project (use the "Product Navigator view").Make sure to select Copy Items when asked if you extracted the code archive outside of your project.
  • Include SNAugusPopView wherever you need it with #import <SNAugusPopView.h>.

Author

Augus

License

SNAugusPopView is available under the MIT license. See the LICENSE for more info.


中文介绍

特性

  • 高性能:该弹出框只依赖系统库和文件,全局只有一份。
  • 自动布局:文本框可以根据外部的参数进行单行和多行的自动布局。
  • 透明度:设置弹出框的透明度不会影响文本透明底,二者并行。
  • 高度自定义:使用者可以任意设置你想设置的属性。
  • 轻量级:该库只有头文件和实现文件,总代码800行左右。
  • 文档和单元测试:文档覆盖率100%,代码覆盖率99.2%。

示例

例子0

// 弹出框的初始化  
self.allPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(50, 700, 0, 0) text:@"请阅读并勾选以下协议勾选以下协议All" direction:SNAugusPopViewDirectionBottom singleLine:YES closeButtonName:@"close" leftImageName:@"left" gradient:YES];
                
// self.allPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(50, 750, 0, 0) text:@"请阅读并勾选以下协议勾选以下协议发发现新的炼金珠女呗冲啊擦法All" direction:SNAugusPopViewDirectionBottom singleLine:NO closeButtonName:@"close" leftImageName:@"left" gradient:YES];

// 添加弹出框到self.view上
[self.view addSubview:self.allPopView];

// 设置弹出框的文本字体大小
self.allPopView.textFont = [UIFont systemFontOfSize:16];
// 设置弹出框的渐变颜色数组
self.allPopView.gradientColors = @[(id)(UIColor.orangeColor.CGColor),(id)UIColor.redColor.CGColor];
// 设置弹出框的渐变起点
self.allPopView.gradientStartPoint = CGPointMake(1.0, 0.5);
// 设置弹出框的渐变终点
self.allPopView.gradientEndPoint = CGPointMake(0.0, 0.5);
// 设置弹出框的渐变影响范围
self.allPopView.gradientLocations = @[@0.5,@1.0];
// 设置关闭按钮的背景色
self.allPopView.closeButtonBackgroundColor = UIColor.blackColor;
// 设置左侧图片视图的背景色
self.allPopView.leftImageBackgroundColor = UIColor.yellowColor;
// 设置左侧图片视图的宽度
self.leftImagePopView.leftImageWidth = 30;
// 设置左侧图片视图的高度
self.leftImagePopView.leftImageHeight = 15;
// 设置左侧图片视图距离右侧视图的距离
self.leftImagePopView.leftImageLabelPadding = 20;
// 显示弹出框
[self.allPopView show];

例子1

self.mulLinesPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(30, 250, 0, 0) text:@"袅袅炊烟,小小村落,路上一道辙,你用你那母亲的脉搏和我诉说,我的祖国和我像海和浪花一朵MulLines" direction:SNAugusPopViewDirectionBottom singleLine:NO gradient:NO];
[self.view addSubview:self.mulLinesPopView];

self.mulLinesPopView.mulLineWidth = 100.0;
self.mulLinesPopView.arrowVerticalPadding = 30.0;
self.mulLinesPopView.textAlignment = NSTextAlignmentLeft;
self.mulLinesPopView.backgroundColor = UIColor.yellowColor;
self.mulLinesPopView.borderWidth = 5.0;
self.mulLinesPopView.borderColor = UIColor.greenColor;

// 设置mulLinesPopView展示2.5秒之后自动消失
[self.mulLinesPopView showWithDismissDelay:2.5];

例子2

self.topPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(160, self.testView.frame.origin.y + 60, 0, 0) text:@"请阅读并勾选以下协议Top" direction:SNAugusPopViewDirectionTop gradient:NO];
[self.view addSubview:self.topPopView];
self.topPopView.delegate = self;
self.topPopView.textFont = [UIFont systemFontOfSize:13];
self.topPopView.arrowHorizontalPadding = 80;
self.topPopView.textColor = UIColor.blueColor;

// 设置topPopView展示3秒之后消失,完成之后不需要进行回调操作
[self.topPopView showWithDismissDelay:3 completion:nil];

例子3

self.bottomPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(100+60, 100-20, 0, 0) text:@"请阅读并勾选以下协议Bottom" direction:SNAugusPopViewDirectionBottom gradient:YES];
self.bottomPopView.delegate = self;
[self.view addSubview:self.bottomPopView];

self.bottomPopView.arrowHorizontalPadding = 80;
self.bottomPopView.textFont = [UIFont systemFontOfSize:16];
self.bottomPopView.gradientColors = @[(id)(UIColor.orangeColor.CGColor),(id)UIColor.redColor.CGColor];
self.bottomPopView.gradientStartPoint = CGPointMake(1.0, 0.5);
self.bottomPopView.gradientEndPoint = CGPointMake(0.0, 0.5);
self.bottomPopView.gradientLocations = @[@0.5,@1.0];

// 设置bottomPopView3.5秒之后消失,完成之后并打印日志
[self.bottomPopView showWithDismissDelay:3.5 completion:^(BOOL finished) {
     NSLog(@"bottom popview dismiss");
}];

例子4

self.leftPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(230, 100+25, 0, 0) text:@"请阅读并勾选以下协议Left" direction:SNAugusPopViewDirectionLeft gradient:NO];
self.leftPopView.delegate = self;
[self.view addSubview:self.leftPopView];

self.leftPopView.textFont = [UIFont systemFontOfSize:10];
self.leftPopView.arrowVerticalPadding = 5.0;
self.leftPopView.aBackgroundRed = 0/255.0;
self.leftPopView.aBackgroundGreen = 191/255.0;
self.leftPopView.aBackgroundBlue = 255/255.0;

[self.leftPopView show];
// 立即消失
[self.leftPopView dismiss];

例子5

self.rightPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(160, 100+25, 0, 0) text:@"请阅读并勾选以下协议Right" direction:SNAugusPopViewDirectionRight gradient:NO];
[self.view addSubview:self.rightPopView];
self.rightPopView.delegate = self;
self.rightPopView.textFont = [UIFont systemFontOfSize:10];
self.rightPopView.arrowVerticalPadding = 5;
self.rightPopView.textColor = UIColor.redColor;

[self.rightPopView showToView:self.view];
// 设置rightPopView4.5秒之后消失
[self.rightPopView dismissDelay:4.5];

例子6

self.closePopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(50, 480, 0, 0) text:@"请阅读并勾选以下协议SingleClose" direction:SNAugusPopViewDirectionBottom singleLine:YES closeButtonName:@"Close" gradient:NO];

[self.closePopView showToView:self.view];
// 设置closePopView5.5秒之后消失,完成之后什么都不做
[self.closePopView dismissDelay:5.5 completion:nil];

例子7

self.leftImagePopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(50, 580, 0, 0) text:@"请阅读并勾选以下协议LeftImage" direction:SNAugusPopViewDirectionBottom singleLine:YES leftImageName:@"left" gradient:NO];
[self.view addSubview:self.leftImagePopView];

self.leftImagePopView.leftImageWidth = 30;
self.leftImagePopView.leftImageHeight = 15;

[self.leftImagePopView showToView:self.view];
// leftImagePopView6.5秒之后消失,完成之后打印日志
[self.leftImagePopView dismissDelay:6.5 completion:^(BOOL finished) {
    NSLog(@"leftImagePopView dismiss completion");
}];

例子8

UILabel *testLabel = [[UILabel alloc] init];
testLabel.frame = CGRectMake(0, 0, 180, 40);
testLabel.text = @"轻击播放键,解放双眼。文案可配置轻击播放键,解放双眼,轻击播放键,解放双眼";
testLabel.numberOfLines = 0;
testLabel.font = [UIFont systemFontOfSize:12];
testLabel.textColor = UIColor.whiteColor;

self.customViewPopView = [[SNAugusPopView alloc] initWithFrame:CGRectMake(200, 280, 0, 0) customView:testLabel direction:SNAugusPopViewDirectionBottom gradient:NO];
self.customViewPopView.arrowHorizontalPadding = 50; 
// Custom use labelHorizontalPadding to set padding to popView's left and right margins.
self.customViewPopView.labelHorizontalPadding = 20;
// Custom use labelVerticalPadding to set padding to popView's top and bottom margins.
self.customViewPopView.labelVerticalPadding = 15;
self.customViewPopView.arrowWidth = 20;
self.customViewPopView.arrowHeight = 12;
[self.view addSubview:self.customViewPopView];

[self.customViewPopView show];

依赖

SNAugusPopView可以运行在iOS 9+的系统版本。它依赖以下的苹果框架,这些框架都已经内嵌在该库中

  • Foundation.framework
  • UIKit.framewrok
  • objc/runtime.h

安装

静态库

你可以为你的目标工程或者项目过程添加SNAugusPopView以一个静态库的形式

  • 首先下载最新版本的代码或者添加代码仓库为你的代码跟踪作为跟踪子模块
  • 使用Xcode打开你的项目,然后拖拽SNAugusPopView.xcodeproj到你的工程或者项目工程
  • 选中你的目标工程,然后去Build phases选项卡,在 Link Binary With Libraries组中点击添加按钮,在下拉列表中找到并添加SNAugusPopView.framework。你可能也需要添加SNAugusPopView到你的目的依赖列表中

Cocoapods

  • 添加一个关于SNAugusPopView第三方库的请求在你的Podfile文件中,SNAugusPopView', '~> 0.1.0
  • 安装这个第三方库,使用pod的命令,pod install
  • 在你需要使用的SNAugusPopView的地方导入头文件,#import <SNAugusPopView.h>

源码文件

与此同时,你也可以直接添加头文件和实现文件到你的工程中

  • 首先下载最新版本的代码或者添加代码仓库为你的代码跟踪作为跟踪子模块
  • 使用Xcode打开你的项目,然后拖拽SNAugusPopView.hSNAugusPopView.m到你的工程或者项目工程,如果你在你的项目之外提取了代码文件,请确保在询问时选择复制项目
  • 在你使用该弹窗的地方导入头文件#import <SNAugusPopView.h>

作者

Augus

许可证

SNAugusPopView是在MIT许可下提供的。更多信息请查阅许可说明

About

A super lightweight popView.

Resources

License

Stars

Watchers

Forks

Packages

No packages published