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

#import <Y5GradientButton.h>

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

Instance Methods

(instancetype) - initWithFrame:andDelegate:
 
(CAGradientLayer *) - makeGradientLayer: [implementation]
 

Detailed Description

Definition at line 17 of file Y5GradientButton.h.

Method Documentation

◆ initWithFrame:andDelegate:()

- (instancetype) initWithFrame: (CGRect)  frame
andDelegate: (id<Y5GradientButtonProtocol>)  delegate 

Definition at line 15 of file Y5GradientButton.m.

15  :(CGRect)frame andDelegate:(id<Y5GradientButtonProtocol>)delegate
16 {
17  self = [UIButton buttonWithType:UIButtonTypeRoundedRect];
18  if (self) {
20  [self setFrame:frame];
21 
22  [self setTitleEdgeInsets:UIEdgeInsetsMake(2, 2, 2, 2)];
23  [self setTitle:@"Hey!" forState:UIControlStateNormal];
24  [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
25  [self setTitleColor:[UIColor yellowColor] forState:UIControlStateSelected];
26  // UIFont *expandedFont = [UIFont fontWithName:@"Verdana-Bold" size:20.0];
27  UIFont *expandedFont = [UIFont fontWithName:@"Verdana-Bold" size:18.0];
28  [self.titleLabel setFont:expandedFont];
29  [self.titleLabel setLineBreakMode:NSLineBreakByWordWrapping];
30  [self.titleLabel setTextAlignment:NSTextAlignmentCenter];
31  [self.titleLabel setAdjustsFontSizeToFitWidth:YES];
32  self.clipsToBounds = YES;
33 
34  CAGradientLayer *gradientLayer = [self makeGradientLayer:NO];
35  [self.layer addSublayer:gradientLayer];
36  }
37  return self;
38 }
id< Y5GradientButtonProtocol > mGradientButtonDelegate
id< U7ParamEditControlDelegate > delegate

◆ makeGradientLayer:()

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

Definition at line 40 of file Y5GradientButton.m.

40  :(Boolean) status
41 {
42 
43  CAGradientLayer *gradientLayer = [CAGradientLayer layer];
44  CGRect overFlowBounds = self.layer.bounds;
45  overFlowBounds.size.height -= 2.0;
46  gradientLayer.frame = overFlowBounds;
47 
48  if (status) {
49  gradientLayer.colors = [NSArray arrayWithObjects:
50  (id)[UIColor colorWithWhite:0.4f alpha:0.5f].CGColor,
51  (id)[UIColor colorWithWhite:1.0f alpha:0.1f].CGColor,
52  nil];
53  } else {
54  gradientLayer.colors = [NSArray arrayWithObjects:
55  (id)[UIColor colorWithWhite:1.0f alpha:0.1f].CGColor,
56  (id)[UIColor colorWithWhite:0.4f alpha:0.5f].CGColor,
57  nil];
58  }
59 
60  gradientLayer.locations = [NSArray arrayWithObjects:
61  [NSNumber numberWithFloat:0.0f],
62  [NSNumber numberWithFloat:1.0f],
63  nil];
64 
65  gradientLayer.cornerRadius = 6; // refillButton.layer.cornerRadius;
66 
67  return gradientLayer;
68 }

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