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

Commit d05004e

Browse files
committed
RKOTopAlert:
1. 随仓库配套一个演示demo,方便参考使用。 2. 修复 文字叠加的问题。 3. 修复 手势与自动消失冲突的问题。 这个版本在使用上应该比较稳定了。目前就差自动布局没有做了。
1 parent 885e26b commit d05004e

File tree

11 files changed

+141
-141
lines changed

11 files changed

+141
-141
lines changed

README.md

+4-12
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ RKOTextView *textViewWithCode = [RKOTextView textViewWithFrame:frame
7878
### RKOTopAlert
7979
8080
<p align="left">
81-
<a href=""><img src="https://img.shields.io/badge/pod-v1.0.2-brightgreen.svg"></a>
81+
<a href=""><img src="https://img.shields.io/badge/pod-v1.0.3-brightgreen.svg"></a>
8282
<a href=""><img src="https://img.shields.io/badge/ObjectiveC-compatible-orange.svg"></a>
8383
<a href=""><img src="https://img.shields.io/badge/platform-iOS%207.0%2B-ff69b5152950834.svg"></a>
8484
<a href="https://github.com/rakuyoMo/RKOTools/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg?style=flat"></a>
@@ -89,23 +89,15 @@ RKOTextView *textViewWithCode = [RKOTextView textViewWithFrame:frame
8989
#### 集成:
9090
9191
```shell
92-
pod 'RKOTopAlert', '~> 1.0.2'
92+
pod 'RKOTopAlert', '~> 1.0.3'
9393
```
9494

9595
#### 使用:
9696

9797
```objc
98-
[RKOTopAlert popAlertViewWithText:@"提醒文字" textColor:[UIColor redColor] ackgroundColor:[UIColor blackColor];
99-
```
100-
101-
或者:
102-
103-
```objc
104-
// 创建单例并设置样式。
105-
RKOTopAlert *topAlert = [[self sharedManager] alertViewWithText:@"提醒文字" textColor:[UIColor whiteColor] ackgroundColor:[UIColor redColor]];
98+
RKOTopAlert *topAlert = [RKOTopAlert alertViewWithText:@"提示文字" textColor:[UIColor whiteColor] ackgroundColor:[UIColor redColor]];
10699

107-
// 出现
108-
[topAlert alertAppearWithDuration:0.3f];
100+
[topAlert alertAppearWithDuration:2.0];
109101
```
110102
111103
---------------------------------------------------------------------

RKOTextViewManager/RKOTextView/RKOTextView/RKOTextView/RKOTextView.m

-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ @interface RKOTextView () <UITextViewDelegate>
2323
// TextView的最大高度。
2424
@property (nonatomic, assign) CGFloat maxTextH;
2525

26-
// 达到最大标志的标识符。
27-
@property (nonatomic, assign) BOOL achMaxTextH;
28-
2926
@end
3027

3128
@implementation RKOTextView

RKOTopAlertManager/README.md

+29-41
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RKOTopAlert
22

33
<p align="center">
4-
<a href=""><img src="https://img.shields.io/badge/pod-v1.0.2-brightgreen.svg"></a>
4+
<a href=""><img src="https://img.shields.io/badge/pod-v1.0.3-brightgreen.svg"></a>
55
<a href=""><img src="https://img.shields.io/badge/ObjectiveC-compatible-orange.svg"></a>
66
<a href=""><img src="https://img.shields.io/badge/platform-iOS%207.0%2B-ff69b5152950834.svg"></a>
77
<a href="https://github.com/rakuyoMo/RKOTools/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg?style=flat"></a>
@@ -11,6 +11,8 @@
1111

1212
自定义一个顶端的`Alert`提示窗。弹出时从顶端向下移动。(**在iPhone X下可用**
1313

14+
随仓库配套了一个简单的 **演示Demo**,方便大家使用参考。
15+
1416
可以设置**提示文字****文字颜色****背景颜色**
1517

1618
**高度**`Status` + `NavigationBar`的高度。(不论您的`ViewController`是否添加到`NavigationController`中)
@@ -30,75 +32,61 @@
3032
## 集成
3133

3234
```shell
33-
pod 'RKOTopAlert', '~> 1.0.2'
35+
pod 'RKOTopAlert', '~> 1.0.3'
3436
```
3537

3638
## 使用
3739

38-
在需要弹出该提示窗的地方调用下面的方法:
40+
使用下面的方法创建一个`Alert`视图,对`Alert`视图调用 `alertAppearWithDuration` 并设置时候,即可弹出 `Alert`视图。
3941

4042
```objc
41-
[RKOTopAlert popAlertViewWithText:@"提醒文字" textColor:[UIColor whiteColor] ackgroundColor:[UIColor redColor];
43+
RKOTopAlert *topAlert = [RKOTopAlert alertViewWithText:@"提示文字" textColor:[UIColor whiteColor] ackgroundColor:[UIColor redColor]];
44+
45+
[topAlert alertAppearWithDuration:2.0];
4246
```
4347
44-
如果您的`App`需要统一多个提示窗的样式,那么推荐您使用下面的方法
48+
如果您的`App`需要统一多个提示窗的样式,那么推荐您在 `AppDelegate` 中进行设置
4549
4650
```objc
47-
// 创建单例并设置样式。
48-
RKOTopAlert *topAlert = [[self sharedManager] alertViewWithText:@"提醒文字" textColor:[UIColor whiteColor] ackgroundColor:[UIColor redColor]];
49-
50-
// 出现
51-
[topAlert alertAppearWithDuration:0.3f];
51+
// 在 AppDelegate.h 中设置属性
52+
@property (nonatomic, strong) RKOTopAlert *topAlert;
53+
54+
// 懒加载属性,创建对象并设置样式。
55+
- (RKOTopAlert *)topAlert {
56+
return [RKOTopAlert alertViewWithText:@"在AppDelegate中总体设置" textColor:[UIColor blackColor] ackgroundColor:[UIColor orangeColor]];
57+
}
58+
59+
// 在按钮方法或其它方法中,获取属性调用弹出方法。
60+
- (IBAction)popAlert:(id)sender {
61+
[((AppDelegate *)[UIApplication sharedApplication].delegate).topAlert alertAppearWithDuration:2.0];
62+
}
5263
```
5364

5465
## 接口
5566

56-
该提示窗提供一个方法用于设置样式并弹出提示窗。
67+
本控件提供一个工厂方法,用以创建对象并设置样式:
5768

5869
```objc
5970
/**
6071
* 设置提示窗的样式,并弹出提示窗。(其对象参数均不可为nil。)
61-
62-
* @param text 提示窗显示文字。
63-
* @param textColor 文字颜色。
64-
* @param backgroundColor 提示窗背景颜色。
65-
* @param duration 横幅持续显示的时间。
66-
*/
67-
+ (void)popAlertViewWithText:(NSString *)text
68-
textColor:(UIColor *)textColor
69-
ackgroundColor:(UIColor *)backgroundColor
70-
duration:(CGFloat)duration;
71-
```
72-
73-
此外,考虑到您可以需要统一的设置多个弹窗,我们提供如下的方法进行设置:
74-
75-
```objc
76-
/**
77-
* 单例方法,创建对象。
78-
79-
* @return 提示窗Alert。
80-
*/
81-
+ (RKOTopAlert *)sharedManager;
82-
83-
/**
84-
* 设置样式。(其对象参数均不可为nil。)
85-
72+
8673
* @param text 提示窗显示文字。
8774
* @param textColor 文字颜色。
8875
* @param backgroundColor 提示窗背景颜色。
76+
* @return 调用对象本身
8977
*/
90-
- (void)alertViewWithText:(NSString *)text
91-
textColor:(UIColor *)textColor
92-
ackgroundColor:(UIColor *)backgroundColor;
78+
+ (instancetype)alertViewWithText:(NSString *)text
79+
textColor:(UIColor *)textColor
80+
ackgroundColor:(UIColor *)backgroundColor;
9381
```
9482

95-
此外,我们分别提供了弹窗弹窗的**弹出**方法与**消失**方法,方便您在他处动态地控制弹窗的弹出与消失
83+
此外,我们分别提供了弹窗弹窗的**弹出**方法与**消失**方法,方便您动态地控制弹窗的弹出与消失
9684

9785
```objc
9886
/**
9987
* 弹出提示窗的方法。
10088
101-
* @param duration 横幅持续显示的时间。
89+
* @param duration 横幅持续显示的时间。如果传0,则需要手动调用alertDisappear方法使视图消失。
10290
*/
10391
- (void)alertAppearWithDuration:(CGFloat)duration;
10492

RKOTopAlertManager/RKOTopAlert.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Pod::Spec.new do |s|
1010

1111
s.name = "RKOTopAlert"
12-
s.version = "1.0.2"
12+
s.version = "1.0.3"
1313
s.summary = "Appears at the top of the notification view"
1414
s.description = <<-DESC
1515
Appears at the top of the notification view
@@ -23,7 +23,7 @@ Pod::Spec.new do |s|
2323

2424
s.ios.deployment_target = "7.0"
2525

26-
s.source = { :git => "https://github.com/rakuyoMo/RKOControls.git", :tag => "1.0.5" } # #{s.version}
26+
s.source = { :git => "https://github.com/rakuyoMo/RKOControls.git", :tag => "1.0.7" } # #{s.version}
2727

2828
s.requires_arc = true
2929

RKOTopAlertManager/RKOTopAlert/RKOTopAlert/AppDelegate.h

+4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88

99
#import <UIKit/UIKit.h>
1010

11+
@class RKOTopAlert;
12+
1113
@interface AppDelegate : UIResponder <UIApplicationDelegate>
1214

1315
@property (strong, nonatomic) UIWindow *window;
1416

17+
// 顶部的提示视图
18+
@property (nonatomic, strong) RKOTopAlert *topAlert;
1519

1620
@end
1721

RKOTopAlertManager/RKOTopAlert/RKOTopAlert/AppDelegate.m

+5
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
//
88

99
#import "AppDelegate.h"
10+
#import "RKOTopAlert.h"
1011

1112
@interface AppDelegate ()
1213

1314
@end
1415

1516
@implementation AppDelegate
1617

18+
#pragma mark - Top Alert
19+
- (RKOTopAlert *)topAlert {
20+
return [RKOTopAlert alertViewWithText:@"在AppDelegate中总体设置" textColor:[UIColor blackColor] ackgroundColor:[UIColor orangeColor]];
21+
}
1722

1823
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
1924
// Override point for customization after application launch.

RKOTopAlertManager/RKOTopAlert/RKOTopAlert/Assets.xcassets/AppIcon.appiconset/Contents.json

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
313
{
414
"idiom" : "iphone",
515
"size" : "29x29",
@@ -29,6 +39,11 @@
2939
"idiom" : "iphone",
3040
"size" : "60x60",
3141
"scale" : "3x"
42+
},
43+
{
44+
"idiom" : "ios-marketing",
45+
"size" : "1024x1024",
46+
"scale" : "1x"
3247
}
3348
],
3449
"info" : {
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,49 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
59
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
610
</dependencies>
711
<scenes>
812
<!--View Controller-->
913
<scene sceneID="tne-QT-ifu">
1014
<objects>
11-
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
15+
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
1216
<layoutGuides>
1317
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
1418
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
1519
</layoutGuides>
1620
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
1721
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1822
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
23+
<subviews>
24+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FwO-hF-kdB">
25+
<rect key="frame" x="156.5" y="374" width="62" height="30"/>
26+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
27+
<state key="normal" title="单独设置"/>
28+
<connections>
29+
<action selector="popAlertTwo:" destination="BYZ-38-t0r" eventType="touchUpInside" id="ATZ-bW-BgN"/>
30+
</connections>
31+
</button>
32+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CAw-NR-hyb">
33+
<rect key="frame" x="120" y="250" width="135" height="30"/>
34+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
35+
<state key="normal" title="AppDelegate中设置"/>
36+
<connections>
37+
<action selector="popAlert:" destination="BYZ-38-t0r" eventType="touchUpInside" id="zYF-QQ-e5q"/>
38+
</connections>
39+
</button>
40+
</subviews>
1941
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2042
</view>
2143
</viewController>
2244
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
2345
</objects>
46+
<point key="canvasLocation" x="117.59999999999999" y="118.29085457271366"/>
2447
</scene>
2548
</scenes>
2649
</document>

RKOTopAlertManager/RKOTopAlert/RKOTopAlert/RKOTopAlert/RKOTopAlert.h

+5-27
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,22 @@ NS_ASSUME_NONNULL_BEGIN
1919

2020
@interface RKOTopAlert : UIView
2121

22-
#pragma mark - 分别设置每个弹窗样式。
2322
/**
2423
* 设置提示窗的样式,并弹出提示窗。(其对象参数均不可为nil。)
2524
2625
* @param text 提示窗显示文字。
2726
* @param textColor 文字颜色。
2827
* @param backgroundColor 提示窗背景颜色。
29-
* @param duration 横幅持续显示的时间。
28+
* @return 调用对象本身
3029
*/
31-
+ (void)popAlertViewWithText:(NSString *)text
32-
textColor:(UIColor *)textColor
33-
ackgroundColor:(UIColor *)backgroundColor
34-
duration:(CGFloat)duration;
35-
36-
#pragma mark - 统一设置App所有弹窗样式
37-
/**
38-
* 单例方法,创建对象。
39-
40-
* @return 提示窗Alert。
41-
*/
42-
+ (RKOTopAlert *)sharedManager;
43-
44-
/**
45-
设置样式。(其对象参数均不可为nil。)
46-
47-
@param text 提示窗显示文字。
48-
@param textColor 文字颜色。
49-
@param backgroundColor 提示窗背景颜色。
50-
*/
51-
- (void)alertViewWithText:(NSString *)text
52-
textColor:(UIColor *)textColor
53-
ackgroundColor:(UIColor *)backgroundColor;
30+
+ (instancetype)alertViewWithText:(NSString *)text
31+
textColor:(UIColor *)textColor
32+
ackgroundColor:(UIColor *)backgroundColor;
5433

5534
/**
5635
* 弹出提示窗的方法。
5736
58-
* @param duration 横幅持续显示的时间。
37+
* @param duration 横幅持续显示的时间。如果传0,则需要手动调用alertDisappear方法使视图消失。
5938
*/
6039
- (void)alertAppearWithDuration:(CGFloat)duration;
6140

@@ -67,4 +46,3 @@ NS_ASSUME_NONNULL_BEGIN
6746
@end
6847

6948
NS_ASSUME_NONNULL_END
70-

0 commit comments

Comments
 (0)