Today's Menu  Portugal
journal and plan nutrition
Z1ContainedLabel.m
Go to the documentation of this file.
1 //
2 // Z1ContainedLabel.m
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 5/1/17.
6 // Copyright © 2017 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 
9 #import "Z1ContainedLabel.h"
10 #import "Z5DataController.h"
11 
12 @implementation Z1ContainedLabel
13 {
14 }
15 
16 - (instancetype) init
17 {
18  self = [super init];
19  if (self) {
20  [self originate];
21  }
22  return self;
23 }
24 - (instancetype) initWithFrame:(CGRect)frame
25 {
26  self = [super initWithFrame:frame];
27  if (self) {
28  [self originateWithFrame:frame];
29  _containedHeight = [NSNumber numberWithFloat:(frame.size.height) - 6.0];
30 
31 
32  }
33  return self;
34 }
35 
36 - (void) originate
37 {
38  _messageLabel = [[UILabel alloc] init];
39  [self styleLabel];
40  [self addSubview:_messageLabel];
41 }
42 
43 - (void) originateWithFrame:(CGRect) frame
44 {
45  CGRect paddedFrame = CGRectMake(frame.origin.x + 2.0, frame.origin.y + 2.0, frame.size.width - 4.0, frame.size.height - 4.0);
46  _messageLabel = [[UILabel alloc] initWithFrame:paddedFrame];
47  [self styleLabel];
48  [self addSubview:_messageLabel];
49 }
50 - (void)styleLabel
51 {
52  [_messageLabel.layer setBorderColor: [[UIColor blackColor] CGColor]];
53  [_messageLabel.layer setBorderWidth: 2.0];
54  _messageLabel.layer.cornerRadius = 8.0f;
55  _messageLabel.layer.masksToBounds = YES;
56 
57  [self.layer setBorderColor: [[UIColor blueColor] CGColor]];
58  [self.layer setBorderWidth: 2.0];
59  self.layer.cornerRadius = 10.0f;
60  self.layer.masksToBounds = YES;
61 }
62 #pragma mark - Z6ContainedView protocol
63 - (float) heightRequirement
64 {
65  return [_containedHeight floatValue] + 6.0;
66 }
67 - (void) appear:(CGRect)bound
68 {
69  NSLog(@"Z1ContainedLabel.appear");
70  CGRect messageLabelFrame = CGRectMake(2.0, 2.0, bound.size.width - 20.0, [self heightRequirement] - 4.0);
71  [_messageLabel setFrame:messageLabelFrame];
72  [_messageLabel setBackgroundColor:[[Z5DataController sharedInstance] wheatColor]];
73 }
74 
75 /*
76 // Only override drawRect: if you perform custom drawing.
77 // An empty implementation adversely affects performance during animation.
78 - (void)drawRect:(CGRect)rect {
79  // Drawing code
80 }
81 */
82 
83 @end
instancetype sharedInstance()
Singleton interface to both core and remote data sources.