Today's Menu  Portugal
journal and plan nutrition
U5MealCollectionViewCell.m
Go to the documentation of this file.
1 //
2 // U5MealCollectionViewCell.m
3 // TodaysMenu
4 //
5 // Created by Don Zeek on 1/3/19
6 // Copyright © 2019 net.dzeek.y2015.ios.portfolio. All rights reserved.
7 //
8 
10 #import "U5MealPanoramaView.h"
11 
12 @interface U5MealCollectionViewCell ()
13 @end
14 
15 @implementation U5MealCollectionViewCell
16 - (id)initWithFrame:(CGRect)frame {
17 
18  self = [super initWithFrame:frame];
19 
20  return self;
21 }
22 // Lazy loading of the imageView
23 - (UIImageView *) imageView
24 {
25  if (!_imageView) {
26  NSValue *imageSizeValue = [U5MealPanoramaView mealCellDefaultSize];
27  CGSize imageSize = [imageSizeValue CGSizeValue];
28  CGRect imageFrame = CGRectMake(0.0, 0.0, imageSize.width, imageSize.height);
29  _imageView = [[UIImageView alloc] initWithFrame:imageFrame];
30  _imageView.tag = 501;
31  [self.contentView addSubview:_imageView];
32  }
33  return _imageView;
34 }
35 // Lazy loading of the textLabel
36 - (UILabel *) textLabel
37 {
38  if (!_textLabel) {
39  NSValue *imageSizeValue = [U5MealPanoramaView mealCellDefaultSize];
40  CGSize imageSize = [imageSizeValue CGSizeValue];
41  float textWidth = 144.0;
42  float textHeight = 38.0;
43  float textLeft = imageSize.width - textWidth;
44  float textTop = imageSize.height - textHeight;
45  CGRect textFrame = CGRectMake(textLeft, textTop, textWidth, textHeight);
46  _textLabel = [[UILabel alloc] initWithFrame:textFrame];
47  _textLabel.backgroundColor = [UIColor colorWithRed:0.3f green:1.0f blue:0.7f alpha:1.0f];
48  _textLabel.textAlignment = NSTextAlignmentCenter;
49  _textLabel.font = [UIFont fontWithName:@"Verdana" size:10.0f];
50  _textLabel.tag = 502;
51 
52  [self.contentView addSubview:_textLabel];
53 
54  // NSLog(@"U5MealCollectionViewCell.textLabel: tag: %ld top/left-widthxheight: %3.2f/%3.2f-%3.2fx%3.2f", (long)[_textLabel tag], textTop, textLeft, textWidth, textHeight);
55  }
56  return _textLabel;
57 }
58 // Here we remove all the custom stuff that we added to our subclassed cell
60 {
61  [super prepareForReuse];
62 
63  [self.imageView removeFromSuperview];
64  [self.textLabel removeFromSuperview];
65  self.imageView = nil;
66  self.textLabel = nil;
67 }
68 
69 @end
UIImageView * imageView
NSValue * mealCellDefaultSize()