Today's Menu  Portugal
journal and plan nutrition
Instance Methods | Class Methods | List of all members
Y3GradientButton Class Reference

#import <Y3GradientButton.h>

Inheritance diagram for Y3GradientButton:
Inheritance graph
[legend]
Collaboration diagram for Y3GradientButton:
Collaboration graph
[legend]

Instance Methods

(void) - showText:
 
(void) - showDepressed:
 

Class Methods

(Y3GradientButton *) + makeGradientButton:withFrame:
 
(Y3GradientButton *) + makeSingleCharacterGradientButton:withFrame:
 
(CAGradientLayer *) + makeGradientLayer: [implementation]
 

Detailed Description

Definition at line 11 of file Y3GradientButton.h.

Method Documentation

◆ makeGradientButton:withFrame:()

+ (Y3GradientButton *) makeGradientButton: (NSString *)  caption
withFrame: (CGRect)  menuButtonFrame 

Definition at line 16 of file Y3GradientButton.m.

16  :(NSString *) caption withFrame: (CGRect) menuButtonFrame {
17  menuButton = [Y3GradientButton buttonWithType:UIButtonTypeRoundedRect];
18  [menuButton setFrame:menuButtonFrame];
19 
20  [menuButton setBackgroundColor:[UIColor colorWithHue:0.23 saturation:0.9 brightness:1.0 alpha:1.0]];
21 
22  menuButton.layer.cornerRadius = 8;
23  menuButton.layer.borderColor = [[UIColor blackColor] CGColor];
24  menuButton.layer.borderWidth = 3.0;
25 
26  [menuButton setTitleEdgeInsets:UIEdgeInsetsMake(2, 2, 2, 2)];
27  [menuButton setTitle:caption forState:UIControlStateNormal];
28  [menuButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
29  [menuButton setTitleColor:[UIColor yellowColor] forState:UIControlStateSelected];
30  // UIFont *expandedFont = [UIFont fontWithName:@"Verdana-Bold" size:20.0];
31  UIFont *expandedFont = [UIFont fontWithName:@"Verdana-Bold" size:18.0];
32  [menuButton.titleLabel setFont:expandedFont];
33  [menuButton.titleLabel setLineBreakMode:NSLineBreakByWordWrapping];
34  [menuButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
35  [menuButton.titleLabel setAdjustsFontSizeToFitWidth:YES];
36  menuButton.clipsToBounds = YES;
37 
38  CAGradientLayer *gradientLayer = [self makeGradientLayer:NO];
39  [menuButton.layer addSublayer:gradientLayer];
40  return menuButton;
41 }
static Y3GradientButton * menuButton

◆ makeGradientLayer:()

+ (CAGradientLayer *) makeGradientLayer: (Boolean)  status
implementation

Definition at line 69 of file Y3GradientButton.m.

69  :(Boolean) status
70 {
71 
72  CAGradientLayer *gradientLayer = [CAGradientLayer layer];
73  CGRect overFlowBounds = menuButton.layer.bounds;
74  overFlowBounds.size.height -= 2.0;
75  gradientLayer.frame = overFlowBounds;
76 
77  if (status) {
78  gradientLayer.colors = [NSArray arrayWithObjects:
79  (id)[UIColor colorWithWhite:0.4f alpha:0.5f].CGColor,
80  (id)[UIColor colorWithWhite:1.0f alpha:0.1f].CGColor,
81  nil];
82  } else {
83  gradientLayer.colors = [NSArray arrayWithObjects:
84  (id)[UIColor colorWithWhite:1.0f alpha:0.1f].CGColor,
85  (id)[UIColor colorWithWhite:0.4f alpha:0.5f].CGColor,
86  nil];
87  }
88 
89  gradientLayer.locations = [NSArray arrayWithObjects:
90  [NSNumber numberWithFloat:0.0f],
91  [NSNumber numberWithFloat:1.0f],
92  nil];
93 
94  gradientLayer.cornerRadius = 6; // refillButton.layer.cornerRadius;
95 
96  return gradientLayer;
97 }
static Y3GradientButton * menuButton

◆ makeSingleCharacterGradientButton:withFrame:()

+ (Y3GradientButton *) makeSingleCharacterGradientButton: (NSString *)  caption
withFrame: (CGRect)  menuButtonFrame 

Definition at line 42 of file Y3GradientButton.m.

42  :(NSString *) caption withFrame: (CGRect) menuButtonFrame {
43  menuButton = [Y3GradientButton buttonWithType:UIButtonTypeRoundedRect];
44  [menuButton setFrame:menuButtonFrame];
45 
46  [menuButton setBackgroundColor:[UIColor colorWithHue:0.23 saturation:0.9 brightness:1.0 alpha:1.0]];
47 
48  menuButton.layer.cornerRadius = 8;
49  menuButton.layer.borderColor = [[UIColor blackColor] CGColor];
50  menuButton.layer.borderWidth = 3.0;
51 
52  [menuButton setTitleEdgeInsets:UIEdgeInsetsMake(2, 2, 2, 2)];
53  [menuButton setTitle:caption forState:UIControlStateNormal];
54  [menuButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
55  [menuButton setTitleColor:[UIColor yellowColor] forState:UIControlStateSelected];
56  // UIFont *expandedFont = [UIFont fontWithName:@"Verdana-Bold" size:20.0];
57  UIFont *expandedFont = [UIFont fontWithName:@"Verdana-Bold" size:40.0];
58  [menuButton.titleLabel setFont:expandedFont];
59  [menuButton.titleLabel setLineBreakMode:NSLineBreakByWordWrapping];
60  [menuButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
61  [menuButton.titleLabel setAdjustsFontSizeToFitWidth:YES];
62  menuButton.clipsToBounds = YES;
63 
64  CAGradientLayer *gradientLayer = [self makeGradientLayer:NO];
65  [menuButton.layer addSublayer:gradientLayer];
66  return menuButton;
67 }
static Y3GradientButton * menuButton

◆ showDepressed:()

- (void) showDepressed: (Boolean)  state

Definition at line 99 of file Y3GradientButton.m.

99  :(Boolean)state
100 {
101  NSLog(@"GradientButton: showDepressed: %@", ( state ? @"PUSHED" : @"RELEASED"));
102  // [self setBackgroundColor:[UIColor colorWithHue:0.13 saturation:0.9 brightness:1.0 alpha:1.0]];
103  [self.layer removeFromSuperlayer];
104 
105  CAGradientLayer *gradientLayer = [Y3GradientButton makeGradientLayer:state];
106  [self.layer addSublayer:gradientLayer];
107 
108 }
CAGradientLayer * makeGradientLayer:(Boolean status)

◆ showText:()

- (void) showText: (NSString *)  caption

Definition at line 110 of file Y3GradientButton.m.

110  :(NSString *) caption
111 {
112  [menuButton setTitle:caption forState:UIControlStateNormal];
113  [menuButton setNeedsDisplay];
114 }

The documentation for this class was generated from the following files: