Permalink
Browse files

Opened up some private ivars on the gradient classes

  • Loading branch information...
coneybeare committed Jan 11, 2012
1 parent 19a5478 commit a520633df190eb6a7698f7a561b76f373e29e87e
@@ -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;
@@ -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
@@ -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
@@ -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;
}
@@ -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 {
@@ -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
@@ -9,6 +9,8 @@
#import "UAViewController.h"
#import "UAExampleModalPanel.h"
+#import "UANoisyGradientBackground.h"
+#import "UAGradientBackground.h"
@implementation UAViewController
@@ -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];

0 comments on commit a520633

Please sign in to comment.