Fixed #7: Replace background image with a gradient

This commit is contained in:
Tito Ciuro
2012-06-03 23:37:58 -07:00
parent 11bba57b07
commit 885038e61d
8 changed files with 154 additions and 17 deletions

View File

@@ -25,6 +25,8 @@
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 */; };
7492FA45157C8CD700FB834C /* WBBlueGradientView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7492FA42157C8CD700FB834C /* WBBlueGradientView.m */; };
7492FA46157C8CD700FB834C /* WBRedGradientView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7492FA44157C8CD700FB834C /* WBRedGradientView.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -57,6 +59,10 @@
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>"; };
7492FA41157C8CD700FB834C /* WBBlueGradientView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBBlueGradientView.h; sourceTree = "<group>"; };
7492FA42157C8CD700FB834C /* WBBlueGradientView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WBBlueGradientView.m; sourceTree = "<group>"; };
7492FA43157C8CD700FB834C /* WBRedGradientView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBRedGradientView.h; sourceTree = "<group>"; };
7492FA44157C8CD700FB834C /* WBRedGradientView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WBRedGradientView.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -161,6 +167,10 @@
592BDDE415645BEE00B78820 /* NoticeView.bundle */,
592BDDE515645BEE00B78820 /* UILabel+WBExtensions.h */,
592BDDE615645BEE00B78820 /* UILabel+WBExtensions.m */,
7492FA41157C8CD700FB834C /* WBBlueGradientView.h */,
7492FA42157C8CD700FB834C /* WBBlueGradientView.m */,
7492FA43157C8CD700FB834C /* WBRedGradientView.h */,
7492FA44157C8CD700FB834C /* WBRedGradientView.m */,
);
name = Private;
sourceTree = "<group>";
@@ -241,6 +251,8 @@
746CBCFC15709E8300B844B1 /* WBBaseNoticeView.m in Sources */,
746CBD001570A1D100B844B1 /* WBErrorNoticeView.m in Sources */,
746CBD081570A8FA00B844B1 /* WBSuccessNoticeView.m in Sources */,
7492FA45157C8CD700FB834C /* WBBlueGradientView.m in Sources */,
7492FA46157C8CD700FB834C /* WBRedGradientView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -0,0 +1,13 @@
//
// WBBlueGradientView.h
// GradientView
//
// Created by Tito Ciuro on 6/3/12.
// Copyright (c) 2012 Webbo, LLC. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface WBBlueGradientView : UIView
@end

View File

@@ -0,0 +1,51 @@
//
// WBBlueGradientView.m
// GradientView
//
// Created by Tito Ciuro on 6/3/12.
// Copyright (c) 2012 Webbo, LLC. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
#import "WBBlueGradientView.h"
@implementation WBBlueGradientView
- (void)drawRect:(CGRect)rect
{
UIColor *redTop = [UIColor colorWithRed:37/255.0f green:122/255.0f blue:185/255.0f alpha:1.0];
UIColor *redBot = [UIColor colorWithRed:18/255.0f green:96/255.0f blue:154/255.0f alpha:1.0];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.bounds;
gradient.colors = [NSArray arrayWithObjects:
(id)redTop.CGColor,
(id)redBot.CGColor,
nil];
gradient.locations = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0f],
[NSNumber numberWithFloat:0.7],
nil];
[self.layer insertSublayer:gradient atIndex:0];
UIView *firstTopBlueLine = [[UIView alloc]initWithFrame:CGRectMake(0.0, 0.0, self.bounds.size.width, 1.0)];
firstTopBlueLine.backgroundColor = [UIColor colorWithRed:105/255.0f green:163/255.0f blue:208/255.0f alpha:1.0];
[self addSubview:firstTopBlueLine];
UIView *secondTopBlueLine = [[UIView alloc]initWithFrame:CGRectMake(0.0, 1.0, self.bounds.size.width, 1.0)];
secondTopBlueLine.backgroundColor = [UIColor colorWithRed:46/255.0f green:126/255.0f blue:188/255.0f alpha:1.0];
[self addSubview:secondTopBlueLine];
UIView *firstBotBlueLine = [[UIView alloc]initWithFrame:CGRectMake(0.0, self.bounds.size.height - 1, self.frame.size.width, 1.0)];
firstBotBlueLine.backgroundColor = [UIColor colorWithRed:18/255.0f green:92/255.0f blue:149/255.0f alpha:1.0];
[self addSubview:firstBotBlueLine];
UIView *secondBotDarkLine = [[UIView alloc]initWithFrame:CGRectMake(0.0, self.bounds.size.height, self.frame.size.width, 1.0)];
secondBotDarkLine.backgroundColor = [UIColor colorWithRed:4/255.0f green:45/255.0f blue:75/255.0f alpha:1.0];
[self addSubview:secondBotDarkLine];
}
@end

View File

@@ -8,6 +8,8 @@
#import "WBNoticeView.h"
#import "WBNoticeView_Private.h"
#import "WBRedGradientView.h"
#import "WBBlueGradientView.h"
#import "UILabel+WBExtensions.h"
#import <QuartzCore/QuartzCore.h>
@@ -15,7 +17,6 @@
@interface WBNoticeView ()
@property(nonatomic, strong) UIView *noticeView;
@property(nonatomic, strong) UIImageView *imageView;
@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) UILabel *messageLabel;
@@ -25,7 +26,7 @@
@implementation WBNoticeView
@synthesize noticeView, imageView, titleLabel, messageLabel;
@synthesize noticeView, titleLabel, messageLabel;
+ (WBNoticeView *)defaultManager
{
@@ -160,7 +161,6 @@
// Locate the images
NSString *path = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:@"NoticeView.bundle"];
NSString *noticeBackgroundImageName = [path stringByAppendingPathComponent:(WBNoticeViewTypeError == noticeType ? @"notice_error.png" : @"notice_success.png")];
NSString *noticeIconImageName = [path stringByAppendingPathComponent:(WBNoticeViewTypeError == noticeType ? @"notice_error_icon.png" : @"notice_success_icon.png")];
NSInteger numberOfLines = 1;
CGFloat messageLineHeight = 30.0;
@@ -210,15 +210,13 @@
hiddenYOrigin = -noticeViewHeight - 20.0;
// Make and add the notice view
self.noticeView = [[UIView alloc]initWithFrame:CGRectMake(0.0, hiddenYOrigin, viewWidth, noticeViewHeight + 10.0)];
if (WBNoticeViewTypeError == noticeType) {
self.noticeView = [[WBRedGradientView alloc]initWithFrame:CGRectMake(0.0, hiddenYOrigin, viewWidth, noticeViewHeight + 10.0)];
} else {
self.noticeView = [[WBBlueGradientView alloc]initWithFrame:CGRectMake(0.0, hiddenYOrigin, viewWidth, noticeViewHeight + 10.0)];
}
[view addSubview:self.noticeView];
// Make and add the image view
self.imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0.0, 0.0, viewWidth, noticeViewHeight + 10.0)];
[self.imageView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
self.imageView.image = [UIImage imageWithContentsOfFile:noticeBackgroundImageName];
[self.noticeView addSubview:self.imageView];
// Make and add the icon view
UIImageView *iconView = [[UIImageView alloc]initWithFrame:CGRectMake(10.0, 10.0, 30.0, 30.0)];
iconView.image = [UIImage imageWithContentsOfFile:noticeIconImageName];
@@ -234,12 +232,12 @@
[self.noticeView addSubview:self.messageLabel];
}
// Add the drop shadow to profileImageView
self.imageView.layer.shadowColor = [[UIColor blackColor]CGColor];
self.imageView.layer.shadowOffset = CGSizeMake(0.0, 3);
self.imageView.layer.shadowOpacity = 0.50;
self.imageView.layer.masksToBounds = NO;
self.imageView.layer.shouldRasterize = YES;
// Add the drop shadow to the notice view
self.noticeView.layer.shadowColor = [[UIColor blackColor]CGColor];
self.noticeView.layer.shadowOffset = CGSizeMake(0.0, 3);
self.noticeView.layer.shadowOpacity = 0.50;
self.noticeView.layer.masksToBounds = NO;
self.noticeView.layer.shouldRasterize = YES;
// Go ahead, display it and then hide it automatically
[UIView animateWithDuration:duration animations:^ {
@@ -269,7 +267,6 @@
{
[self.noticeView removeFromSuperview];
self.noticeView = nil;
self.imageView = nil;
self.titleLabel = nil;
self.messageLabel = nil;
}

View File

@@ -0,0 +1,13 @@
//
// WBRedGradientView.h
// GradientView
//
// Created by Tito Ciuro on 6/3/12.
// Copyright (c) 2012 Webbo, LLC. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface WBRedGradientView : UIView
@end

View File

@@ -0,0 +1,51 @@
//
// WBRedGradientView.m
// GradientView
//
// Created by Tito Ciuro on 6/3/12.
// Copyright (c) 2012 Webbo, LLC. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
#import "WBRedGradientView.h"
@implementation WBRedGradientView
- (void)drawRect:(CGRect)rect
{
UIColor *redTop = [UIColor colorWithRed:167/255.0f green:26/255.0f blue:20/255.0f alpha:1.0];
UIColor *redBot = [UIColor colorWithRed:134/255.0f green:9/255.0f blue:7/255.0f alpha:1.0];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.bounds;
gradient.colors = [NSArray arrayWithObjects:
(id)redTop.CGColor,
(id)redBot.CGColor,
nil];
gradient.locations = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0f],
[NSNumber numberWithFloat:0.7],
nil];
[self.layer insertSublayer:gradient atIndex:0];
UIView *firstTopPinkLine = [[UIView alloc]initWithFrame:CGRectMake(0.0, 0.0, self.bounds.size.width, 1.0)];
firstTopPinkLine.backgroundColor = [UIColor colorWithRed:211/255.0f green:82/255.0f blue:80/255.0f alpha:1.0];
[self addSubview:firstTopPinkLine];
UIView *secondTopRedLine = [[UIView alloc]initWithFrame:CGRectMake(0.0, 1.0, self.bounds.size.width, 1.0)];
secondTopRedLine.backgroundColor = [UIColor colorWithRed:193/255.0f green:30/255.0f blue:23/255.0f alpha:1.0];
[self addSubview:secondTopRedLine];
UIView *firstBotRedLine = [[UIView alloc]initWithFrame:CGRectMake(0.0, self.bounds.size.height - 1, self.frame.size.width, 1.0)];
firstBotRedLine.backgroundColor = [UIColor colorWithRed:134/255.0f green:9/255.0f blue:7/255.0f alpha:1.0];
[self addSubview:firstBotRedLine];
UIView *secondBotDarkLine = [[UIView alloc]initWithFrame:CGRectMake(0.0, self.bounds.size.height, self.frame.size.width, 1.0)];
secondBotDarkLine.backgroundColor = [UIColor colorWithRed:52/255.0f green:4/255.0f blue:3/255.0f alpha:1.0];
[self addSubview:secondBotDarkLine];
}
@end