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

Commit

Permalink
RKOTopAlert:
Browse files Browse the repository at this point in the history
1. 随仓库配套一个演示demo,方便参考使用。
2. 修复 文字叠加的问题。
3. 修复 手势与自动消失冲突的问题。

这个版本在使用上应该比较稳定了。目前就差自动布局没有做了。
  • Loading branch information
rakuyoMo committed Sep 24, 2017
1 parent 885e26b commit d05004e
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 141 deletions.
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ RKOTextView *textViewWithCode = [RKOTextView textViewWithFrame:frame
### RKOTopAlert
<p align="left">
<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/pod-v1.0.3-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 @@ -89,23 +89,15 @@ RKOTextView *textViewWithCode = [RKOTextView textViewWithFrame:frame
#### 集成:
```shell
pod 'RKOTopAlert', '~> 1.0.2'
pod 'RKOTopAlert', '~> 1.0.3'
```

#### 使用:

```objc
[RKOTopAlert popAlertViewWithText:@"提醒文字" textColor:[UIColor redColor] ackgroundColor:[UIColor blackColor];
```
或者:
```objc
// 创建单例并设置样式。
RKOTopAlert *topAlert = [[self sharedManager] alertViewWithText:@"提醒文字" textColor:[UIColor whiteColor] ackgroundColor:[UIColor redColor]];
RKOTopAlert *topAlert = [RKOTopAlert alertViewWithText:@"提示文字" textColor:[UIColor whiteColor] ackgroundColor:[UIColor redColor]];

// 出现
[topAlert alertAppearWithDuration:0.3f];
[topAlert alertAppearWithDuration:2.0];
```
---------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ @interface RKOTextView () <UITextViewDelegate>
// TextView的最大高度。
@property (nonatomic, assign) CGFloat maxTextH;

// 达到最大标志的标识符。
@property (nonatomic, assign) BOOL achMaxTextH;

@end

@implementation RKOTextView
Expand Down
70 changes: 29 additions & 41 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.2-brightgreen.svg"></a>
<a href=""><img src="https://img.shields.io/badge/pod-v1.0.3-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 @@ -11,6 +11,8 @@

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

随仓库配套了一个简单的 **演示Demo**,方便大家使用参考。

可以设置**提示文字****文字颜色****背景颜色**

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

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

## 使用

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

```objc
[RKOTopAlert popAlertViewWithText:@"提醒文字" textColor:[UIColor whiteColor] ackgroundColor:[UIColor redColor];
RKOTopAlert *topAlert = [RKOTopAlert alertViewWithText:@"提示文字" textColor:[UIColor whiteColor] ackgroundColor:[UIColor redColor]];

[topAlert alertAppearWithDuration:2.0];
```
如果您的`App`需要统一多个提示窗的样式,那么推荐您使用下面的方法
如果您的`App`需要统一多个提示窗的样式,那么推荐您在 `AppDelegate` 中进行设置
```objc
// 创建单例并设置样式。
RKOTopAlert *topAlert = [[self sharedManager] alertViewWithText:@"提醒文字" textColor:[UIColor whiteColor] ackgroundColor:[UIColor redColor]];
// 出现
[topAlert alertAppearWithDuration:0.3f];
// 在 AppDelegate.h 中设置属性
@property (nonatomic, strong) RKOTopAlert *topAlert;
// 懒加载属性,创建对象并设置样式。
- (RKOTopAlert *)topAlert {
return [RKOTopAlert alertViewWithText:@"在AppDelegate中总体设置" textColor:[UIColor blackColor] ackgroundColor:[UIColor orangeColor]];
}
// 在按钮方法或其它方法中,获取属性调用弹出方法。
- (IBAction)popAlert:(id)sender {
[((AppDelegate *)[UIApplication sharedApplication].delegate).topAlert alertAppearWithDuration:2.0];
}
```

## 接口

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

```objc
/**
* 设置提示窗的样式,并弹出提示窗。(其对象参数均不可为nil。)
* @param text 提示窗显示文字。
* @param textColor 文字颜色。
* @param backgroundColor 提示窗背景颜色。
* @param duration 横幅持续显示的时间。
*/
+ (void)popAlertViewWithText:(NSString *)text
textColor:(UIColor *)textColor
ackgroundColor:(UIColor *)backgroundColor
duration:(CGFloat)duration;
```

此外,考虑到您可以需要统一的设置多个弹窗,我们提供如下的方法进行设置:

```objc
/**
* 单例方法,创建对象。
* @return 提示窗Alert。
*/
+ (RKOTopAlert *)sharedManager;

/**
* 设置样式。(其对象参数均不可为nil。)
* @param text 提示窗显示文字。
* @param textColor 文字颜色。
* @param backgroundColor 提示窗背景颜色。
* @return 调用对象本身
*/
- (void)alertViewWithText:(NSString *)text
textColor:(UIColor *)textColor
ackgroundColor:(UIColor *)backgroundColor;
+ (instancetype)alertViewWithText:(NSString *)text
textColor:(UIColor *)textColor
ackgroundColor:(UIColor *)backgroundColor;
```

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

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

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.2"
s.version = "1.0.3"
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.5" } # #{s.version}
s.source = { :git => "https://github.com/rakuyoMo/RKOControls.git", :tag => "1.0.7" } # #{s.version}

s.requires_arc = true

Expand Down
4 changes: 4 additions & 0 deletions RKOTopAlertManager/RKOTopAlert/RKOTopAlert/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

#import <UIKit/UIKit.h>

@class RKOTopAlert;

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

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

@end

5 changes: 5 additions & 0 deletions RKOTopAlertManager/RKOTopAlert/RKOTopAlert/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
//

#import "AppDelegate.h"
#import "RKOTopAlert.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

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

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -29,6 +39,11 @@
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,49 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<?xml version="1.0" encoding="UTF-8"?>
<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">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FwO-hF-kdB">
<rect key="frame" x="156.5" y="374" width="62" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="单独设置"/>
<connections>
<action selector="popAlertTwo:" destination="BYZ-38-t0r" eventType="touchUpInside" id="ATZ-bW-BgN"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CAw-NR-hyb">
<rect key="frame" x="120" y="250" width="135" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="AppDelegate中设置"/>
<connections>
<action selector="popAlert:" destination="BYZ-38-t0r" eventType="touchUpInside" id="zYF-QQ-e5q"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="117.59999999999999" y="118.29085457271366"/>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,22 @@ NS_ASSUME_NONNULL_BEGIN

@interface RKOTopAlert : UIView

#pragma mark - 分别设置每个弹窗样式。
/**
* 设置提示窗的样式,并弹出提示窗。(其对象参数均不可为nil。)
* @param text 提示窗显示文字。
* @param textColor 文字颜色。
* @param backgroundColor 提示窗背景颜色。
* @param duration 横幅持续显示的时间。
* @return 调用对象本身
*/
+ (void)popAlertViewWithText:(NSString *)text
textColor:(UIColor *)textColor
ackgroundColor:(UIColor *)backgroundColor
duration:(CGFloat)duration;

#pragma mark - 统一设置App所有弹窗样式
/**
* 单例方法,创建对象。
* @return 提示窗Alert。
*/
+ (RKOTopAlert *)sharedManager;

/**
设置样式。(其对象参数均不可为nil。)
@param text 提示窗显示文字。
@param textColor 文字颜色。
@param backgroundColor 提示窗背景颜色。
*/
- (void)alertViewWithText:(NSString *)text
textColor:(UIColor *)textColor
ackgroundColor:(UIColor *)backgroundColor;
+ (instancetype)alertViewWithText:(NSString *)text
textColor:(UIColor *)textColor
ackgroundColor:(UIColor *)backgroundColor;

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

Expand All @@ -67,4 +46,3 @@ NS_ASSUME_NONNULL_BEGIN
@end

NS_ASSUME_NONNULL_END

Loading

0 comments on commit d05004e

Please sign in to comment.