mirror of
https://github.com/zhigang1992/NoticeView.git
synced 2026-01-12 17:32:41 +08:00
new version 2. The README doc contains more info.
This commit is contained in:
@@ -22,6 +22,9 @@
|
||||
59A782461562F5F80001F08D /* MainStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 59A782441562F5F70001F08D /* MainStoryboard.storyboard */; };
|
||||
59A782491562F5F80001F08D /* WBViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 59A782481562F5F80001F08D /* WBViewController.m */; };
|
||||
59A782591562F8750001F08D /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 59A782581562F8750001F08D /* QuartzCore.framework */; };
|
||||
746CBCFC15709E8300B844B1 /* WBBaseNoticeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 746CBCFB15709E8300B844B1 /* WBBaseNoticeView.m */; };
|
||||
746CBD001570A1D100B844B1 /* WBErrorNoticeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 746CBCFF1570A1D100B844B1 /* WBErrorNoticeView.m */; };
|
||||
746CBD081570A8FA00B844B1 /* WBSuccessNoticeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 746CBD071570A8FA00B844B1 /* WBSuccessNoticeView.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -47,6 +50,13 @@
|
||||
59A782471562F5F80001F08D /* WBViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WBViewController.h; sourceTree = "<group>"; };
|
||||
59A782481562F5F80001F08D /* WBViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WBViewController.m; sourceTree = "<group>"; };
|
||||
59A782581562F8750001F08D /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
|
||||
746CBCFA15709E8300B844B1 /* WBBaseNoticeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBBaseNoticeView.h; sourceTree = "<group>"; };
|
||||
746CBCFB15709E8300B844B1 /* WBBaseNoticeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WBBaseNoticeView.m; sourceTree = "<group>"; };
|
||||
746CBCFE1570A1D100B844B1 /* WBErrorNoticeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBErrorNoticeView.h; sourceTree = "<group>"; };
|
||||
746CBCFF1570A1D100B844B1 /* WBErrorNoticeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WBErrorNoticeView.m; sourceTree = "<group>"; };
|
||||
746CBD011570A65D00B844B1 /* WBNoticeView_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WBNoticeView_Private.h; sourceTree = "<group>"; };
|
||||
746CBD061570A8FA00B844B1 /* WBSuccessNoticeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBSuccessNoticeView.h; sourceTree = "<group>"; };
|
||||
746CBD071570A8FA00B844B1 /* WBSuccessNoticeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WBSuccessNoticeView.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -77,11 +87,11 @@
|
||||
592BDDE315645BEE00B78820 /* WBNoticeView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
592BDDE715645BEE00B78820 /* WBNoticeView.h */,
|
||||
592BDDE815645BEE00B78820 /* WBNoticeView.m */,
|
||||
592BDDE415645BEE00B78820 /* NoticeView.bundle */,
|
||||
592BDDE515645BEE00B78820 /* UILabel+WBExtensions.h */,
|
||||
592BDDE615645BEE00B78820 /* UILabel+WBExtensions.m */,
|
||||
746CBCFE1570A1D100B844B1 /* WBErrorNoticeView.h */,
|
||||
746CBCFF1570A1D100B844B1 /* WBErrorNoticeView.m */,
|
||||
746CBD061570A8FA00B844B1 /* WBSuccessNoticeView.h */,
|
||||
746CBD071570A8FA00B844B1 /* WBSuccessNoticeView.m */,
|
||||
746CBD051570A88800B844B1 /* Private */,
|
||||
);
|
||||
path = WBNoticeView;
|
||||
sourceTree = "<group>";
|
||||
@@ -140,6 +150,21 @@
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
746CBD051570A88800B844B1 /* Private */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
592BDDE715645BEE00B78820 /* WBNoticeView.h */,
|
||||
592BDDE815645BEE00B78820 /* WBNoticeView.m */,
|
||||
746CBD011570A65D00B844B1 /* WBNoticeView_Private.h */,
|
||||
592BDDE415645BEE00B78820 /* NoticeView.bundle */,
|
||||
592BDDE515645BEE00B78820 /* UILabel+WBExtensions.h */,
|
||||
592BDDE615645BEE00B78820 /* UILabel+WBExtensions.m */,
|
||||
746CBCFA15709E8300B844B1 /* WBBaseNoticeView.h */,
|
||||
746CBCFB15709E8300B844B1 /* WBBaseNoticeView.m */,
|
||||
);
|
||||
name = Private;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
@@ -213,6 +238,9 @@
|
||||
59A782491562F5F80001F08D /* WBViewController.m in Sources */,
|
||||
592BDDEC15645BEE00B78820 /* UILabel+WBExtensions.m in Sources */,
|
||||
592BDDED15645BEE00B78820 /* WBNoticeView.m in Sources */,
|
||||
746CBCFC15709E8300B844B1 /* WBBaseNoticeView.m in Sources */,
|
||||
746CBD001570A1D100B844B1 /* WBErrorNoticeView.m in Sources */,
|
||||
746CBD081570A8FA00B844B1 /* WBSuccessNoticeView.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
25
NoticeView/WBNoticeView/WBBaseNoticeView.h
Normal file
25
NoticeView/WBNoticeView/WBBaseNoticeView.h
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// WBBaseNoticeView.h
|
||||
// NoticeView
|
||||
//
|
||||
// Created by Tito Ciuro on 5/25/12.
|
||||
// Copyright (c) 2012 Tito Ciuro. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WBNoticeView.h"
|
||||
|
||||
@interface WBBaseNoticeView : WBNoticeView
|
||||
|
||||
- (void)show;
|
||||
|
||||
@property (nonatomic, readwrite) WBNoticeViewType noticeType;
|
||||
|
||||
@property (nonatomic, strong) UIView *view;
|
||||
@property (nonatomic, strong) NSString *title;
|
||||
|
||||
@property (nonatomic, readwrite) CGFloat duration;
|
||||
@property (nonatomic, readwrite) CGFloat delay;
|
||||
@property (nonatomic, readwrite) CGFloat alpha;
|
||||
@property (nonatomic, readwrite) CGFloat originY;
|
||||
|
||||
@end
|
||||
26
NoticeView/WBNoticeView/WBBaseNoticeView.m
Normal file
26
NoticeView/WBNoticeView/WBBaseNoticeView.m
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// WBBaseNoticeView.m
|
||||
// NoticeView
|
||||
//
|
||||
// Created by Tito Ciuro on 5/25/12.
|
||||
// Copyright (c) 2012 Tito Ciuro. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WBBaseNoticeView.h"
|
||||
|
||||
@implementation WBBaseNoticeView
|
||||
|
||||
@synthesize noticeType;
|
||||
@synthesize view;
|
||||
@synthesize title;
|
||||
@synthesize duration;
|
||||
@synthesize delay;
|
||||
@synthesize alpha;
|
||||
@synthesize originY;
|
||||
|
||||
- (void)show
|
||||
{
|
||||
// Subclasses need to override this method...
|
||||
}
|
||||
|
||||
@end
|
||||
17
NoticeView/WBNoticeView/WBErrorNoticeView.h
Normal file
17
NoticeView/WBNoticeView/WBErrorNoticeView.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// WBErrorNoticeView.h
|
||||
// NoticeView
|
||||
//
|
||||
// Created by Tito Ciuro on 5/25/12.
|
||||
// Copyright (c) 2012 Tito Ciuro. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WBBaseNoticeView.h"
|
||||
|
||||
@interface WBErrorNoticeView : WBBaseNoticeView
|
||||
|
||||
+ (WBErrorNoticeView *)errorNoticeInView:(UIView *)view title:(NSString *)title message:(NSString *)message;
|
||||
|
||||
@property (nonatomic, strong) NSString *message;
|
||||
|
||||
@end
|
||||
39
NoticeView/WBNoticeView/WBErrorNoticeView.m
Normal file
39
NoticeView/WBNoticeView/WBErrorNoticeView.m
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// WBErrorNoticeView.m
|
||||
// NoticeView
|
||||
//
|
||||
// Created by Tito Ciuro on 5/25/12.
|
||||
// Copyright (c) 2012 Tito Ciuro. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WBErrorNoticeView.h"
|
||||
#import "WBNoticeView_Private.h"
|
||||
|
||||
@implementation WBErrorNoticeView
|
||||
|
||||
@synthesize message;
|
||||
|
||||
+ (WBErrorNoticeView *)errorNoticeInView:(UIView *)view title:(NSString *)title message:(NSString *)message
|
||||
{
|
||||
WBErrorNoticeView *notice = [WBErrorNoticeView new];
|
||||
|
||||
notice.view = view;
|
||||
notice.title = title;
|
||||
notice.message = message;
|
||||
|
||||
return notice;
|
||||
}
|
||||
|
||||
- (void)show
|
||||
{
|
||||
[self _showNoticeOfType:WBNoticeViewTypeError
|
||||
view:self.view
|
||||
title:self.title
|
||||
message:self.message
|
||||
duration:self.duration
|
||||
delay:self.delay
|
||||
alpha:self.alpha
|
||||
yOrigin:self.originY];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
@interface WBNoticeView : NSObject
|
||||
|
||||
typedef enum {
|
||||
WBNoticeViewTypeError = 0,
|
||||
WBNoticeViewTypeSuccess
|
||||
} WBNoticeViewType;
|
||||
|
||||
+ (WBNoticeView *)defaultManager;
|
||||
|
||||
// Error notice methods
|
||||
|
||||
@@ -7,15 +7,11 @@
|
||||
//
|
||||
|
||||
#import "WBNoticeView.h"
|
||||
#import "WBNoticeView_Private.h"
|
||||
#import "UILabel+WBExtensions.h"
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
typedef enum {
|
||||
WBNoticeViewTypeError = 0,
|
||||
WBNoticeViewTypeSuccess
|
||||
} WBNoticeViewType;
|
||||
|
||||
@interface WBNoticeView ()
|
||||
|
||||
@property(nonatomic, strong) UIView *noticeView;
|
||||
@@ -23,15 +19,6 @@ typedef enum {
|
||||
@property(nonatomic, strong) UILabel *titleLabel;
|
||||
@property(nonatomic, strong) UILabel *messageLabel;
|
||||
|
||||
- (void)_showNoticeOfType:(WBNoticeViewType)noticeType
|
||||
view:(UIView *)view
|
||||
title:(NSString *)title
|
||||
message:(NSString *)message
|
||||
duration:(float)duration
|
||||
delay:(float)delay
|
||||
alpha:(float)alpha
|
||||
yOrigin:(CGFloat)origin;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WBNoticeView
|
||||
@@ -157,7 +144,7 @@ typedef enum {
|
||||
alpha:(float)alpha
|
||||
yOrigin:(CGFloat)origin
|
||||
{
|
||||
if (nil == noticeView) {
|
||||
if (nil == self.noticeView) {
|
||||
// Sanity check
|
||||
if (nil == view) {
|
||||
[[NSException exceptionWithName:NSInvalidArgumentException
|
||||
@@ -170,7 +157,8 @@ typedef enum {
|
||||
if (nil == message) message = @"Information not provided.";
|
||||
if (0.0 == duration) duration = 0.5;
|
||||
if (0.0 == delay) delay = 2.0;
|
||||
|
||||
if (0.0 == alpha) alpha = 1.0;
|
||||
|
||||
// Obtain the screen width
|
||||
CGFloat viewWidth = view.frame.size.width;
|
||||
|
||||
@@ -271,10 +259,10 @@ typedef enum {
|
||||
} completion:^ (BOOL finished) {
|
||||
if (finished) {
|
||||
// Cleanup
|
||||
noticeView = nil;
|
||||
imageView = nil;
|
||||
titleLabel = nil;
|
||||
messageLabel = nil;
|
||||
self.noticeView = nil;
|
||||
self.imageView = nil;
|
||||
self.titleLabel = nil;
|
||||
self.messageLabel = nil;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
27
NoticeView/WBNoticeView/WBNoticeView_Private.h
Normal file
27
NoticeView/WBNoticeView/WBNoticeView_Private.h
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// WBNoticeView_Private.h
|
||||
// NoticeView
|
||||
//
|
||||
// Created by Tito Ciuro on 5/25/12.
|
||||
// Copyright (c) 2012 Tito Ciuro. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef NoticeView_WBNoticeView_Private_h
|
||||
#define NoticeView_WBNoticeView_Private_h
|
||||
|
||||
#import "WBNoticeView.h"
|
||||
|
||||
@interface WBNoticeView (Private)
|
||||
|
||||
- (void)_showNoticeOfType:(WBNoticeViewType)noticeType
|
||||
view:(UIView *)view
|
||||
title:(NSString *)title
|
||||
message:(NSString *)message
|
||||
duration:(float)duration
|
||||
delay:(float)delay
|
||||
alpha:(float)alpha
|
||||
yOrigin:(CGFloat)origin;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
15
NoticeView/WBNoticeView/WBSuccessNoticeView.h
Normal file
15
NoticeView/WBNoticeView/WBSuccessNoticeView.h
Normal file
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// WBSuccessNoticeView.h
|
||||
// NoticeView
|
||||
//
|
||||
// Created by Tito Ciuro on 5/25/12.
|
||||
// Copyright (c) 2012 Tito Ciuro. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WBBaseNoticeView.h"
|
||||
|
||||
@interface WBSuccessNoticeView : WBBaseNoticeView
|
||||
|
||||
+ (WBSuccessNoticeView *)successNoticeInView:(UIView *)view title:(NSString *)title;
|
||||
|
||||
@end
|
||||
38
NoticeView/WBNoticeView/WBSuccessNoticeView.m
Normal file
38
NoticeView/WBNoticeView/WBSuccessNoticeView.m
Normal file
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// WBSuccessNoticeView.m
|
||||
// NoticeView
|
||||
//
|
||||
// Created by Tito Ciuro on 5/25/12.
|
||||
// Copyright (c) 2012 Tito Ciuro. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WBSuccessNoticeView.h"
|
||||
#import "WBNoticeView_Private.h"
|
||||
|
||||
@implementation WBSuccessNoticeView
|
||||
|
||||
@synthesize title;
|
||||
|
||||
+ (WBSuccessNoticeView *)successNoticeInView:(UIView *)view title:(NSString *)title
|
||||
{
|
||||
WBSuccessNoticeView *notice = [WBSuccessNoticeView new];
|
||||
|
||||
notice.view = view;
|
||||
notice.title = title;
|
||||
|
||||
return notice;
|
||||
}
|
||||
|
||||
- (void)show
|
||||
{
|
||||
[self _showNoticeOfType:WBNoticeViewTypeSuccess
|
||||
view:self.view
|
||||
title:self.title
|
||||
message:nil
|
||||
duration:self.duration
|
||||
delay:self.delay
|
||||
alpha:self.alpha
|
||||
yOrigin:self.originY];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#import "WBViewController.h"
|
||||
#import "WBNoticeView.h"
|
||||
#import "WBErrorNoticeView.h"
|
||||
#import "WBSuccessNoticeView.h"
|
||||
|
||||
@interface WBViewController ()
|
||||
|
||||
@@ -63,55 +65,50 @@
|
||||
|
||||
- (IBAction)showSmallErrorNotice:(id)sender
|
||||
{
|
||||
WBNoticeView *nm = [WBNoticeView defaultManager];
|
||||
[nm showErrorNoticeInView:self.view title:@"Network Error" message:@"Check your network connection."];
|
||||
WBErrorNoticeView *notice = [WBErrorNoticeView errorNoticeInView:self.view title:@"Network Error" message:@"Check your network connection."];
|
||||
[notice show];
|
||||
}
|
||||
|
||||
- (IBAction)showLargeErrorNotice:(id)sender
|
||||
{
|
||||
WBNoticeView *nm = [WBNoticeView defaultManager];
|
||||
[nm showErrorNoticeInView:self.view title:@"Network Error" message:@"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."];
|
||||
WBErrorNoticeView *notice = [WBErrorNoticeView errorNoticeInView:self.view title:@"Network Error" message:@"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."];
|
||||
[notice show];
|
||||
}
|
||||
|
||||
- (IBAction)showSmallSuccessNotice:(id)sender
|
||||
{
|
||||
WBNoticeView *nm = [WBNoticeView defaultManager];
|
||||
[nm showSuccessNoticeInView:self.view message:@"Link Saved Successfully"];
|
||||
WBSuccessNoticeView *notice = [WBSuccessNoticeView successNoticeInView:self.view title:@"Link Saved Successfully"];
|
||||
[notice show];
|
||||
}
|
||||
|
||||
- (IBAction)showSmallErrorNoticeBelow:(id)sender
|
||||
{
|
||||
WBNoticeView *nm = [WBNoticeView defaultManager];
|
||||
[nm showErrorNoticeInView:self.view
|
||||
title:@"Network Error"
|
||||
message:@"Check your network connection."
|
||||
duration:0.0
|
||||
delay:0.0
|
||||
alpha:0.8
|
||||
yOrigin:self.headerView.frame.size.height];
|
||||
WBErrorNoticeView *notice = [WBErrorNoticeView errorNoticeInView:self.view title:@"Network Error" message:@"Check your network connection."];
|
||||
|
||||
notice.alpha = 0.8;
|
||||
notice.originY = self.headerView.frame.size.height;
|
||||
|
||||
[notice show];
|
||||
}
|
||||
|
||||
- (IBAction)showLargeErrorNoticeBelow:(id)sender
|
||||
{
|
||||
WBNoticeView *nm = [WBNoticeView defaultManager];
|
||||
[nm showErrorNoticeInView:self.view
|
||||
title:@"Network Error"
|
||||
message:@"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."
|
||||
duration:0.0
|
||||
delay:0.0
|
||||
alpha:0.8
|
||||
yOrigin:self.headerView.frame.size.height];
|
||||
WBErrorNoticeView *notice = [WBErrorNoticeView errorNoticeInView:self.view title:@"Network Error" message:@"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."];
|
||||
|
||||
notice.alpha = 0.8;
|
||||
notice.originY = self.headerView.frame.size.height;
|
||||
|
||||
[notice show];
|
||||
}
|
||||
|
||||
- (IBAction)showSmallSuccessNoticeBelow:(id)sender
|
||||
{
|
||||
WBNoticeView *nm = [WBNoticeView defaultManager];
|
||||
[nm showSuccessNoticeInView:self.view
|
||||
message:@"Link Saved Successfully"
|
||||
duration:0.0
|
||||
delay:0.0
|
||||
alpha:0.8
|
||||
yOrigin:self.headerView.frame.size.height];
|
||||
WBSuccessNoticeView *notice = [WBSuccessNoticeView successNoticeInView:self.view title:@"Link Saved Successfully"];
|
||||
|
||||
notice.alpha = 0.8;
|
||||
notice.originY = self.headerView.frame.size.height;
|
||||
|
||||
[notice show];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
40
README.md
40
README.md
@@ -3,7 +3,7 @@
|
||||
A TweetBot-like notice component for iOS.
|
||||
|
||||
<br/>
|
||||

|
||||

|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
@@ -12,26 +12,47 @@ A TweetBot-like notice component for iOS.
|
||||
* Drop the WBNoticeView folder in your project
|
||||
* Add QuartzCore.framework to your project
|
||||
|
||||
### NoticeView 1.0 vs 2.0
|
||||
|
||||
The behavior in version 1 was "fire and forget". Calling *showErrorNoticeInView* or *showSuccessNoticeInView* displayed the notice, but there was no way to retain it for later use. Version 2 allows the developer to instantiate a notice, customize it (optional) and show it. Not only it's possible to retain it, but also customize it anytime with say, a different title and message. Oh, yeah… and it's cleaner too.
|
||||
|
||||
### Examples
|
||||
|
||||
Since version 2 is more flexible, I have eliminated the older examples and replaced them with the new API. Please note that the older API is still there, for backward compatibility.
|
||||
<br/><br/>
|
||||
|
||||
To display a small error notice:
|
||||
|
||||
WBNoticeView *nm = [WBNoticeView defaultManager];
|
||||
[nm showErrorNoticeInView:self.view title:@"Network Error" message:@"Check your network connection."];
|
||||
WBErrorNoticeView *notice = [WBErrorNoticeView errorNoticeInView:self.view title:@"Network Error" message:@"Check your network connection."];
|
||||
[notice show];
|
||||
|
||||
To display a large error notice, make the text long enough to wrap to another line. Only two lines are supported. If the text doesn't fit in two lines, an ellipsis will be appended at the end of the second line:
|
||||
If the message provided doesn't fit in one line, the notice will be enlarged to accommodate the text:
|
||||
|
||||
WBNoticeView *nm = [WBNoticeView defaultManager];
|
||||
[nm showErrorNoticeInView:self.view title:@"Network Error" message:@"Check your network connection. Twitter could also be down."];
|
||||
WBErrorNoticeView *notice = [WBErrorNoticeView errorNoticeInView:self.view title:@"Network Error" message:@"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."];
|
||||
[notice show];
|
||||
|
||||
To display a small success notice:
|
||||
|
||||
WBNoticeView *nm = [WBNoticeView defaultManager];
|
||||
[nm showSuccessNoticeInView:self.view message:@"Link Saved Successfully"];
|
||||
WBSuccessNoticeView *notice = [WBSuccessNoticeView successNoticeInView:self.view title:@"Link Saved Successfully"];
|
||||
[notice show];
|
||||
|
||||
### Customizing the Notice
|
||||
|
||||
Instead of piling up a bunch of arguments in a method call, I decided to use properties instead. This way, new properties can be added easily without having to clutter the API with specialized methods.
|
||||
|
||||
Example: customize a success notice with a bit of transparency and placing the notice at a specific Y coordinate:
|
||||
|
||||
WBSuccessNoticeView *notice = [WBSuccessNoticeView successNoticeInView:self.view title:@"Link Saved Successfully"];
|
||||
|
||||
notice.alpha = 0.8;
|
||||
notice.originY = self.headerView.frame.size.height;
|
||||
|
||||
[notice show];
|
||||
|
||||
|
||||
## Notes
|
||||
|
||||
If you pass nil instead of a valid UIView, an NSInvalidArgumentException exception will be raised.
|
||||
> If you pass nil instead of a valid UIView, an NSInvalidArgumentException exception will be raised.
|
||||
|
||||
The default values are the following:
|
||||
|
||||
@@ -39,6 +60,7 @@ The default values are the following:
|
||||
if (nil == message) message = @"Information not provided.";
|
||||
if (0.0 == duration) duration = 0.5;
|
||||
if (0.0 == delay) delay = 2.0;
|
||||
if (0.0 == alpha) alpha = 1.0;
|
||||
|
||||
## Contribute
|
||||
|
||||
|
||||
Reference in New Issue
Block a user