Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pikacode committed Oct 31, 2017
1 parent 11fb16d commit 2f65175
Show file tree
Hide file tree
Showing 21 changed files with 352 additions and 81 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified EBBannerView/.DS_Store
Binary file not shown.
119 changes: 83 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Email:[email protected]

QQ群: 345192153



# EBBannerView

Only one line to show:
Expand All @@ -22,18 +24,25 @@ And more:

- autosize portrait/landscape frame
- show a custom view with different frame in portrait/landscape
- custom view has different animation mode, appear from top/left/right/left/center


- NSNotification with click event and pass a value
- support simulator





## Screenshot

![](https://github.com/pikacode/EBBannerView/screenshot/screenshot02.gif)
### System style:

![](screenshot/3.gif)



### Custom style:

![](screenshot/4.gif)



Expand All @@ -49,29 +58,28 @@ And more:


## Usage


### System style

---

```objc
#import <EBBannerView.h>
```

2 ways to use:


there are 3 ways to use:

#### 1.Show a iOS style banner with one line

up to system version,will show iOS 9/10/11 style,auto show app icon/name.

```objc
[EBBannerView showWithContent:@"custom content"];
```
##### Parameters:
- default icon: app icon
- default title: app name
- `default date`: u should set localized string @"现在" = @"now"
- `content`:banner content, NSString
- default style:will show iOS9/10/11 style up to system version
Expand All @@ -92,17 +100,19 @@ banner.content = @"custom content";
[banner show];
```



##### Parameters:

(if not set will use default values)

- `style`:the iOS style, type enum : NSInteger {9/10/11}
- `style`:the iOS style, default is up to system version, type enum : NSInteger {9/10/11}

- `icon`:the icon, type UIImage
- `icon`:the icon, default is app icon, type UIImage

- `title`:the title, type NSString
- `title`:the title, default is app name, type NSString

- `date`:the date, type NSString
- `date`:the date, default is localized string @"现在" = @"now", type NSString

- `content`:the content, type NSString

Expand All @@ -124,33 +134,70 @@ banner.content = @"custom content";



### Custom style

#### 3.Show a totally custom view
---

```objc
//1.create new class CustomView and implement EBCustomBannerViewProtocol
@interface CustomView : UIView<EBCustomBannerViewProtocol>
@property(nonatomic, assign)CGRect portraitFrame;
@property(nonatomic, assign)CGRect landscapeFrame;
//... optional properties
@end
#import <EBCustomBannerView.h>
```

{...
//2.create a CustomView instance
CustomView *customView = [[CustomView alloc] initWith...];

//3.set portrait/landscape frame
customView.portraitFrame = CGRectMake(0, 50, 100, 150);
customView.landscapeFrame = CGRectMake(200, 250, 300, 350);

//4.show
[EBBannerView showWithCustomView:customView];
...}
2 ways to use:



#### 1.create and show immediately

```objc
UIView *view = ...;//the view want to show

[EBCustomBannerView showCustomView:view block:^(EBCustomBannerViewMaker *make) {
make.portraitFrame = ...;//frame in portrait
make.portraitMode = EBCustomViewAppearModeTop;//appear from top in portrait
make.soundID = 1312;
make.stayDuration = 3.0;
//......
}];
```
## Handle click event and pass value
#### 2.create and show after
```objc
UIView *view = ...;//the view want to show
//1.
EBCustomBannerView *customView = [EBCustomBannerView customView:view block:^(EBCustomBannerViewMaker *make) {
make.portraitFrame = ...;
make.portraitMode = EBCustomViewAppearModeTop;
make.soundID = 1312;
make.stayDuration = 3.0;
//......
}];
//2.
[customView show];
//[customView hide];
```



##### Parameters:

- `portraitFrame`: frame in portrait,default is view.frame,type CGRect
- `landscapeFrame`: frame in landscape,default is view.frame,type CGRect
- `soundID`: (the same as `system style`'s)
- `soundName`: (the same as `system style`'s)
- `animationDuration`: (the same as `system style`'s)
- `stayDuration`: (the same as `system style`'s)
- `portraitMode`: in portrait view appears from top/bottom/left/right/center, default is top, type enum
- `landscapeMode`: in landscape view appears from top/bottom/left/right/center, default is top, type enum
- `centerModeDurations`: the animation time of view appears from center, default is @[@0.3, @0.2, @0.1], `animationDuration` is invalid for center animation



## Handle click event and pass value (system style)

- add an observer for `EBBannerViewDidClickNotification` and handle click event
- pass an object when init the banner, and get it when clicked
Expand Down
122 changes: 88 additions & 34 deletions README_CHS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ view [English README.md](/README.md)
Email:[email protected]

QQ群: 345192153



# EBBannerView

只需一行代码即可:
Expand All @@ -23,17 +26,26 @@ QQ群: 345192153
- 完全自定义弹出的 view,自定义 view 在横竖屏时可以定制不同的 frame
- 自定义 view 在横竖屏时支持分别从不同方向弹出(屏幕上下左右中心)
- 监听点击事件、传值
- 支持模拟器和真机




## 效果

![](https://github.com/pikacode/EBBannerView/screenshot/screenshot01.gif)
### 系统推送通知样式:

![](screenshot/1.gif)



### 自定义样式:

![](screenshot/2.gif)



## 安装

### pod 安装

target 'YourTargetName' do
Expand All @@ -42,29 +54,30 @@ QQ群: 345192153




## 使用



### 系统样式

---

```objc
#import <EBBannerView.h>
```

系统样式有两种使用方式:


有以下三种使用方式:

#### 方式一:一行代码搞定之省心模式

根据系统不同自动展示 iOS 9/10/11 的样式,并自动展示 app 名称 图标等。

```objc
[EBBannerView showWithContent:@"自定义内容"];
```
##### 参数说明
- 图标默认显示:app 的图标
- 标题默认显示:app 的名称
- 时间默认显示:NSLocalizedString(@"现在", nil)
- `content`:指定展示的内容,类型 NSString
- 样式:根据系统判断自动展示 iOS9/10/11 的样式
Expand All @@ -84,14 +97,16 @@ banner.content = @"自定义内容";
[banner show];
```



##### 参数说明

(以下参数不赋值时均使用默认值)

- `style`:需要展示的样式,类型 enum : NSInteger {9/10/11}
- `icon`:图片,类型 UIImage
- `title`:标题,类型 NSString
- `date`:时间,类型 NSString
- `style`:需要展示的样式,默认值 系统类型,类型 enum : NSInteger {9/10/11}
- `icon`:图片,默认值 app 的图标,类型 UIImage
- `title`:标题,默认值 app 的名称,类型 NSString
- `date`:时间,默认值 NSLocalizedString(@"现在", nil),类型 NSString
- `content`:内容,类型 NSString
- `animationTime`:显示/隐藏动画时间,类型 NSTimeInterval
- `stayTime`:隐藏之前停留显示的时间,类型 NSTimeInterval
Expand All @@ -105,32 +120,71 @@ banner.content = @"自定义内容";



#### 方式三:完全自定义展示的 view

### 自定义样式

---

```objc
//1.新建类 CustomView,需遵从 EBCustomBannerViewProtocol 协议
@interface CustomView : UIView<EBCustomBannerViewProtocol>
@property(nonatomic, assign)CGRect portraitFrame;
@property(nonatomic, assign)CGRect landscapeFrame;
//...其他参数可选添加
@end
#import <EBCustomBannerView.h>
```

{...
//2.创建 CustomView 实例
CustomView *customView = [[CustomView alloc] initWith...];

//3.分别指定横竖屏时的 frame
customView.portraitFrame = CGRectMake(0, 50, 100, 150);
customView.landscapeFrame = CGRectMake(200, 250, 300, 350);

//4.展示
[EBBannerView showWithCustomView:customView];
...}
自定义样式有两种使用方式:



#### 方式一:构造并立刻展示:

```objc
UIView *view = ...;//需要展示的某个 view

[EBCustomBannerView showCustomView:view block:^(EBCustomBannerViewMaker *make) {
make.portraitFrame = ...;//竖屏时的 frame
make.portraitMode = EBCustomViewAppearModeTop;//竖屏时弹出方向
make.soundID = 1312;//声音
make.stayDuration = 3.0;//停留时间
//......
}];
```
## 监听、处理点击事件、传值
#### 方式二:构造并稍后展示:
```objc
UIView *view = ...;//需要展示的某个 view
//1.传入 view,并构造必要的参数
EBCustomBannerView *customView = [EBCustomBannerView customView:view block:^(EBCustomBannerViewMaker *make) {
make.portraitFrame = ...;//竖屏时的 frame
make.portraitMode = EBCustomViewAppearModeTop;//竖屏时弹出方向
make.soundID = 1312;//声音
make.stayDuration = 3.0;//停留时间
//......
}];
//2.展示
[customView show];
//[customView hide];
```



##### 参数说明:

- `portraitFrame`:竖屏时的 frame,默认值 view.frame,类型 CGRect
- `landscapeFrame`:横屏时的 frame,默认值 view.frame,类型 CGRect
- `soundID`:参见系统样式中参数说明
- `soundName`:参见系统样式中参数说明
- `animationDuration`:参见系统样式中参数说明
- `stayDuration`:参见系统样式中参数说明
- `portraitMode`:竖屏时 view 出现的方向,上/下/左/右/中,默认值 Top,类型 enum
- `landscapeMode`:横屏时 view 出现的方向,上/下/左/右/中,默认值 Top,类型 enum
- `centerModeDurations`:view 从中心出现的动画时间,默认值 @[@0.3, @0.2, @0.1],中心出现的动画 `animationDuration` 参数无效



## 监听、处理点击事件、传值(系统样式)

- 通过监听`EBBannerViewDidClickNotification`通知,处理点击事件。
- 如果初始化 banner 的时候传了 object 的值,在点击后可以获取到。
Expand Down
Binary file modified demo/.DS_Store
Binary file not shown.
Binary file added demo/Pods/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file added demo/Pods/Headers/Public/.DS_Store
Binary file not shown.
Loading

0 comments on commit 2f65175

Please sign in to comment.