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

#import <DLStarView.h>

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

Instance Methods

(id) - initWithDefault:highlighted:position:allowFractions:
 
(void) - centerIn:with:
 
(void) - setStarImage:highlightedStarImage:
 
(UIImage *) - croppedImage:
 
(UIView *) - hitTest:withEvent: [implementation]
 

Detailed Description

Definition at line 17 of file DLStarView.h.

Method Documentation

◆ centerIn:with:()

- (void) centerIn: (CGRect)  _frame
with: (int)  numberOfStars 

Definition at line 67 of file DLStarView.m.

67  :(CGRect)_frame with:(int)numberOfStars {
68  CGSize size = self.frame.size;
69 
70  float height = self.frame.size.height;
71  float frameHeight = _frame.size.height;
72  float newY = (frameHeight-height)/2;
73 
74  float widthOfStars = self.frame.size.width * numberOfStars;
75  float frameWidth = _frame.size.width;
76  float gapToApply = (frameWidth-widthOfStars)/2;
77 
78  self.frame = CGRectMake((size.width*self.tag) + gapToApply, newY, size.width, size.height);
79 }

◆ croppedImage:()

- (UIImage *) croppedImage: (UIImage*)  image

Definition at line 44 of file DLStarView.m.

44  :(UIImage*)image {
45  float partWidth = image.size.width/kNumberOfFractions * image.scale;
46  int part = (self.tag+kNumberOfFractions)%kNumberOfFractions;
47  float xOffset = partWidth*part;
48  CGRect newFrame = CGRectMake(xOffset, 0, partWidth , image.size.height * image.scale);
49  CGImageRef resultImage = CGImageCreateWithImageInRect([image CGImage], newFrame);
50  UIImage *result = [UIImage imageWithCGImage:resultImage scale:image.scale orientation:image.imageOrientation];
51  CGImageRelease(resultImage);
52  return result;
53 }
#define kNumberOfFractions

◆ hitTest:withEvent:()

- (UIView *) hitTest: (CGPoint)  point
withEvent: (UIEvent *)  event 
implementation

Definition at line 60 of file DLStarView.m.

60  :(CGPoint)point withEvent:(UIEvent *)event {
61  return self.superview;
62 }

◆ initWithDefault:highlighted:position:allowFractions:()

- (id) initWithDefault: (UIImage*)  star
highlighted: (UIImage*)  highlightedStar
position: (int)  index
allowFractions: (BOOL)  fractions 

Definition at line 21 of file DLStarView.m.

21  :(UIImage*)star highlighted:(UIImage*)highlightedStar position:(int)index allowFractions:(BOOL)fractions {
22  self = [super initWithFrame:CGRectZero];
23 
24  if (self) {
25  [self setTag:index];
26  if (fractions) {
27  highlightedStar = [self croppedImage:highlightedStar];
28  star = [self croppedImage:star];
29  }
30  self.frame = CGRectMake((star.size.width*index), 0, star.size.width, star.size.height+kEdgeInsetBottom);
31  [self setStarImage:star highlightedStarImage:highlightedStar];
32  [self setImageEdgeInsets:UIEdgeInsetsMake(0, 0, kEdgeInsetBottom, 0)];
33  [self setBackgroundColor:[UIColor clearColor]];
34  if (index == 0) {
35  [self setAccessibilityLabel:@"1 star"];
36  } else {
37  [self setAccessibilityLabel:[NSString stringWithFormat:@"%d stars", index+1]];
38  }
39  }
40  return self;
41 }
#define kEdgeInsetBottom
Definition: DLStarView.h:15

◆ setStarImage:highlightedStarImage:()

- (void) setStarImage: (UIImage*)  starImage
highlightedStarImage: (UIImage*)  highlightedImage 

Definition at line 81 of file DLStarView.m.

81  :(UIImage*)starImage highlightedStarImage:(UIImage*)highlightedImage {
82  [self setImage:starImage forState:UIControlStateNormal];
83  [self setImage:highlightedImage forState:UIControlStateSelected];
84  [self setImage:highlightedImage forState:UIControlStateHighlighted];
85 }

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