Skip to content

Commit

Permalink
Opened up some private ivars on the gradient classes
Browse files Browse the repository at this point in the history
  • Loading branch information
coneybeare committed Jan 11, 2012
1 parent 19a5478 commit a520633
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
Binary file not shown.
9 changes: 6 additions & 3 deletions UAModalPanel/UAGradientBackground.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ typedef enum {
} UAGradientLineMode;

@interface UAGradientBackground : UIView {
int gradientStyle;
CGFloat *colorComponents;
UAGradientLineMode lineMode;
UAGradientBackgroundStyle gradientStyle;
UAGradientLineMode lineMode;
CGFloat *colorComponents;
}

@property (nonatomic, assign) UAGradientBackgroundStyle gradientStyle;
@property (nonatomic, assign) UAGradientLineMode lineMode;

- (id)initWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle color:(CGFloat *)components lineMode:(UAGradientLineMode)lineModes;
- (id)initWithFrame:(CGRect)frame color:(CGFloat *)components;
- (id)initWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle;
Expand Down
2 changes: 2 additions & 0 deletions UAModalPanel/UAGradientBackground.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

@implementation UAGradientBackground

@synthesize gradientStyle, lineMode;

- (id)initWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle color:(CGFloat *)components lineMode:(UAGradientLineMode)lineModes {
if ((self = [super initWithFrame:frame])) {
// Initialization code
Expand Down
12 changes: 6 additions & 6 deletions UAModalPanel/UANoisyGradientBackground.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
#import "UAGradientBackground.h"

@interface UANoisyGradientBackground : UAGradientBackground {
CGFloat opacity;
CGFloat noiseOpacity;
CGBlendMode blendMode;
}

@property (nonatomic, assign) CGFloat opacity;
@property (nonatomic, assign) CGFloat noiseOpacity;
@property (nonatomic, assign) CGBlendMode blendMode;

- (id)initWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle color:(CGFloat *)components lineMode:(UAGradientLineMode)lineModes noiseOpacity:(CGFloat)noiseOpacity blendMode:(CGBlendMode)mode;
- (id)initWithFrame:(CGRect)frame noiseOpacity:(CGFloat)noiseOpacity;
- (id)initWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle color:(CGFloat *)components lineMode:(UAGradientLineMode)lineModes noiseOpacity:(CGFloat)opacity blendMode:(CGBlendMode)mode;
- (id)initWithFrame:(CGRect)frame noiseOpacity:(CGFloat)opacity;
- (id)initWithFrame:(CGRect)frame blendMode:(CGFloat)mode;

+ (id)gradientWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle color:(CGFloat *)components lineMode:(UAGradientLineMode)lineModes noiseOpacity:(CGFloat)noiseOpacity blendMode:(CGBlendMode)mode;
+ (id)gradientWithFrame:(CGRect)frame noiseOpacity:(CGFloat)noiseOpacity;
+ (id)gradientWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle color:(CGFloat *)components lineMode:(UAGradientLineMode)lineModes noiseOpacity:(CGFloat)opacity blendMode:(CGBlendMode)mode;
+ (id)gradientWithFrame:(CGRect)frame noiseOpacity:(CGFloat)opacity;
+ (id)gradientWithFrame:(CGRect)frame blendMode:(CGFloat)mode;

@end
18 changes: 9 additions & 9 deletions UAModalPanel/UANoisyGradientBackground.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@

@implementation UANoisyGradientBackground

@synthesize opacity, blendMode;
@synthesize noiseOpacity, blendMode;


- (id)initWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle color:(CGFloat *)components lineMode:(UAGradientLineMode)lineModes noiseOpacity:(CGFloat)noiseOpacity blendMode:(CGBlendMode)mode {
- (id)initWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle color:(CGFloat *)components lineMode:(UAGradientLineMode)lineModes noiseOpacity:(CGFloat)opacity blendMode:(CGBlendMode)mode {
if ((self = [self initWithFrame:frame style:aStyle color:components lineMode:lineModes])) {
self.opacity = noiseOpacity;
self.noiseOpacity = opacity;
self.blendMode = mode;
}
return self;
}
- (id)initWithFrame:(CGRect)frame noiseOpacity:(CGFloat)noiseOpacity {
- (id)initWithFrame:(CGRect)frame noiseOpacity:(CGFloat)opacity {
if (self = [self initWithFrame:frame]) {
self.opacity = noiseOpacity;
self.noiseOpacity = opacity;
}
return self;
}
Expand All @@ -41,20 +41,20 @@ - (id)initWithFrame:(CGRect)frame blendMode:(CGFloat)mode {
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.opacity = NOISE_DEFAULT_OPACITY;
self.noiseOpacity = NOISE_DEFAULT_OPACITY;
self.blendMode = kCGBlendModeNormal;
}
return self;
}



+ (id)gradientWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle color:(CGFloat *)components lineMode:(UAGradientLineMode)lineModes noiseOpacity:(CGFloat)noiseOpacity blendMode:(CGBlendMode)mode {
+ (id)gradientWithFrame:(CGRect)frame style:(UAGradientBackgroundStyle)aStyle color:(CGFloat *)components lineMode:(UAGradientLineMode)lineModes noiseOpacity:(CGFloat)opacity blendMode:(CGBlendMode)mode {
return [[[UANoisyGradientBackground alloc] initWithFrame:frame
style:aStyle
color:components
lineMode:lineModes
noiseOpacity:noiseOpacity
noiseOpacity:opacity
blendMode:mode] autorelease];
}
+ (id)gradientWithFrame:(CGRect)frame noiseOpacity:(CGFloat)noiseOpacity {
Expand All @@ -69,7 +69,7 @@ + (id)gradientWithFrame:(CGRect)frame blendMode:(CGFloat)mode {
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];

[self drawCGNoiseWithOpacity:self.opacity blendMode:self.blendMode];
[self drawCGNoiseWithOpacity:self.noiseOpacity blendMode:self.blendMode];
}

@end
Expand Down
8 changes: 8 additions & 0 deletions UAModalPanel/UAViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#import "UAViewController.h"

#import "UAExampleModalPanel.h"
#import "UANoisyGradientBackground.h"
#import "UAGradientBackground.h"

@implementation UAViewController

Expand Down Expand Up @@ -74,6 +76,12 @@ - (IBAction)showModalPanel:(id)sender {
// The background color gradient of the title
CGFloat colors[8] = {0, 0, 1, 1, 1, 0, 0, 1};
[[(UATitledModalPanel *)self.currentPanel titleBar] setColorComponents:colors];
// The gradient style (Linear, linear reversed, radial, radial reversed, center highlight). Default = Linear
[[(UATitledModalPanel *)self.currentPanel titleBar] setGradientStyle:UAGradientBackgroundStyleCenterHighlight];
// The line mode of the gradient view (top, bottom, both, none). Top is a white line, bottom is a black line.
[[(UATitledModalPanel *)self.currentPanel titleBar] setLineMode:UAGradientLineModeNone];
// The noise layer opacity. Default = 0.4
[[(UATitledModalPanel *)self.currentPanel titleBar] setNoiseOpacity:0.8];

// The header label, a UILabel with the same frame as the titleBar
[(UATitledModalPanel *)self.currentPanel headerLabel].font = [UIFont boldSystemFontOfSize:48];
Expand Down

0 comments on commit a520633

Please sign in to comment.