Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
修复 点击弹窗后弹窗消失后,再次弹窗时,快速靠近弹窗弹窗消失的bug。
Browse files Browse the repository at this point in the history
  • Loading branch information
rakuyoMo committed Sep 23, 2017
1 parent b27ffe0 commit 75647ba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ RKOTextView *textViewWithCode = [RKOTextView textViewWithFrame:frame
### RKOTopAlert
<p align="left">
<a href=""><img src="https://img.shields.io/badge/pod-v1.0.1-brightgreen.svg"></a>
<a href=""><img src="https://img.shields.io/badge/pod-v1.0.2-brightgreen.svg"></a>
<a href=""><img src="https://img.shields.io/badge/ObjectiveC-compatible-orange.svg"></a>
<a href=""><img src="https://img.shields.io/badge/platform-iOS%207.0%2B-ff69b5152950834.svg"></a>
<a href="https://github.com/rakuyoMo/RKOTools/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg?style=flat"></a>
Expand All @@ -90,7 +90,7 @@ RKOTextView *textViewWithCode = [RKOTextView textViewWithFrame:frame
#### 集成:
```shell
pod 'RKOTopAlert', '~> 1.0.1'
pod 'RKOTopAlert', '~> 1.0.2'
```

#### 使用:
Expand Down
4 changes: 2 additions & 2 deletions RKOTopAlertManager/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# RKOTopAlert

<p align="center">
<a href=""><img src="https://img.shields.io/badge/pod-v1.0.1-brightgreen.svg"></a>
<a href=""><img src="https://img.shields.io/badge/pod-v1.0.2-brightgreen.svg"></a>
<a href=""><img src="https://img.shields.io/badge/ObjectiveC-compatible-orange.svg"></a>
<a href=""><img src="https://img.shields.io/badge/platform-iOS%207.0%2B-ff69b5152950834.svg"></a>
<a href="https://github.com/rakuyoMo/RKOTools/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg?style=flat"></a>
Expand Down Expand Up @@ -30,7 +30,7 @@
## 集成

```shell
pod 'RKOTopAlert', '~> 1.0.1'
pod 'RKOTopAlert', '~> 1.0.2'
```

## 使用
Expand Down
4 changes: 2 additions & 2 deletions RKOTopAlertManager/RKOTopAlert.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Pod::Spec.new do |s|

s.name = "RKOTopAlert"
s.version = "1.0.1"
s.version = "1.0.2"
s.summary = "Appears at the top of the notification view"
s.description = <<-DESC
Appears at the top of the notification view
Expand All @@ -23,7 +23,7 @@ Pod::Spec.new do |s|

s.ios.deployment_target = "7.0"

s.source = { :git => "https://github.com/rakuyoMo/RKOControls.git", :tag => "1.0.4" } # #{s.version}
s.source = { :git => "https://github.com/rakuyoMo/RKOControls.git", :tag => "1.0.5" } # #{s.version}

s.requires_arc = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ @interface RKOTopAlert()
// 文字的颜色。
@property (nonatomic, strong) UIColor *textColor;

// 标记视图已经出现
@property (nonatomic, assign) BOOL alertDidAppear;
// 标记视图将要消失
@property (nonatomic, assign) BOOL alertWillDisappear;

@end

Expand Down Expand Up @@ -112,6 +112,8 @@ - (void)setText:(NSString *)text {
// 出现的动画
- (void)alertAppearWithDuration:(CGFloat)duration {

NSLog(@"alertAppearWithDuration");

// 如果已经被添加,则不再出现。
if (self.superview) {
return;
Expand All @@ -129,7 +131,6 @@ - (void)alertAppearWithDuration:(CGFloat)duration {
self.frame = alertFrame;
} completion:^(BOOL finished) { // 显示动画完成
if (finished) {
self.alertDidAppear = YES;

// duration秒后横幅自动消失
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
Expand All @@ -144,14 +145,18 @@ - (void)alertAppearWithDuration:(CGFloat)duration {
// 消失的动画。
- (void)alertDisappear {

if (!self.alertDidAppear) {
if (self.alertWillDisappear) {
self.alertWillDisappear = NO;
return;
}

__block CGRect alertFrame = self.frame;
//移除横幅动画,设置完全透明并从父视图中移除
[UIView animateWithDuration:ALERT_DISAPPEAR_ANIMATE_DURATION
animations:^{

self.alertWillDisappear = YES;

// 向上移动消失。
alertFrame.origin.y = -topHight.alertViewH;
self.frame = alertFrame;
Expand All @@ -165,8 +170,6 @@ - (void)alertDisappear {
self.backgroundColor = nil;
// 从父视图中移除。
[self removeFromSuperview];

self.alertDidAppear = NO;
}
}];
}
Expand Down

0 comments on commit 75647ba

Please sign in to comment.