Skip to content

Commit

Permalink
Use UIImageView as the background image for default cell.
Browse files Browse the repository at this point in the history
  • Loading branch information
René Sprotte committed Nov 27, 2012
1 parent ed37946 commit 906f5e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions MMGridView/MMGridViewDefaultCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ @implementation MMGridViewDefaultCell
@synthesize textLabel;
@synthesize textLabelBackgroundView;
@synthesize backgroundView;
@synthesize imageView;



Expand All @@ -38,6 +39,10 @@ - (id)initWithFrame:(CGRect)frame
self.backgroundView.backgroundColor = [UIColor lightGrayColor];
[self addSubview:self.backgroundView];

// Image view
self.imageView = [[UIImageView alloc] initWithFrame:CGRectNull];
[self addSubview:self.imageView];

// Label
self.textLabelBackgroundView = [[UIView alloc] initWithFrame:CGRectNull];
self.textLabelBackgroundView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
Expand Down Expand Up @@ -67,6 +72,10 @@ - (void)layoutSubviews
self.backgroundView.frame = self.bounds;
self.backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

// Image view
self.imageView.frame = self.bounds;
self.imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

// Layout label
self.textLabelBackgroundView.frame = CGRectMake(0,
self.bounds.size.height - labelHeight - inset,
Expand Down
3 changes: 2 additions & 1 deletion MMGridViewDemo/RootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ - (MMGridViewCell *)gridView:(MMGridView *)gridView cellAtIndex:(NSUInteger)inde
{
MMGridViewDefaultCell *cell = [[MMGridViewDefaultCell alloc] initWithFrame:CGRectNull];
cell.textLabel.text = [NSString stringWithFormat:@"Cell %d", index];
cell.backgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell-image.png"]];
cell.imageView.image = [UIImage imageNamed:@"cell-image.png"];

return cell;
}

Expand Down

0 comments on commit 906f5e3

Please sign in to comment.