Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to a reusable base cell and a default cell implementation. T…
…his makes it easy to create custom sub classes.
- Loading branch information
René Sprotte
committed
Apr 10, 2011
1 parent
6215039
commit d0ffb3a
Showing
6 changed files
with
114 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// MMGridViewDefaultCell.h | ||
// MMGridView | ||
// | ||
// Created by René Sprotte on 10.04.11. | ||
// Copyright 2011 metaminded. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "MMGridViewCell.h" | ||
|
||
|
||
@interface MMGridViewDefaultCell : MMGridViewCell | ||
{ | ||
UILabel *textLabel; | ||
UIView *textLabelBackgroundView; | ||
UIView *backgroundView; | ||
} | ||
|
||
@property (nonatomic, retain) UILabel *textLabel; | ||
@property (nonatomic, retain) UIView *textLabelBackgroundView; | ||
@property (nonatomic, retain) UIView *backgroundView; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// | ||
// MMGridViewDefaultCell.m | ||
// MMGridView | ||
// | ||
// Created by René Sprotte on 10.04.11. | ||
// Copyright 2011 metaminded. All rights reserved. | ||
// | ||
|
||
#import "MMGridViewDefaultCell.h" | ||
|
||
|
||
@implementation MMGridViewDefaultCell | ||
|
||
@synthesize textLabel; | ||
@synthesize textLabelBackgroundView; | ||
@synthesize backgroundView; | ||
|
||
- (void)dealloc | ||
{ | ||
[textLabel release]; | ||
[textLabelBackgroundView release]; | ||
[backgroundView release]; | ||
[super dealloc]; | ||
} | ||
|
||
|
||
- (id)initWithFrame:(CGRect)frame | ||
{ | ||
if ((self = [super initWithFrame:frame])) { | ||
// Background view | ||
self.backgroundView = [[UIView alloc] initWithFrame:CGRectNull]; | ||
self.backgroundView.backgroundColor = [UIColor lightGrayColor]; | ||
[self addSubview:self.backgroundView]; | ||
|
||
// Label | ||
self.textLabelBackgroundView = [[UIView alloc] initWithFrame:CGRectNull]; | ||
self.textLabelBackgroundView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7]; | ||
|
||
self.textLabel = [[UILabel alloc] initWithFrame:CGRectNull]; | ||
self.textLabel.textAlignment = UITextAlignmentRight; | ||
self.textLabel.backgroundColor = [UIColor clearColor]; | ||
self.textLabel.textColor = [UIColor whiteColor]; | ||
self.textLabel.font = [UIFont systemFontOfSize:12]; | ||
|
||
[self.textLabelBackgroundView addSubview:self.textLabel]; | ||
[self addSubview:self.textLabelBackgroundView]; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
|
||
- (void)layoutSubviews | ||
{ | ||
[super layoutSubviews]; | ||
|
||
int labelHeight = 30; | ||
int inset = 5; | ||
|
||
// Background view | ||
self.backgroundView.frame = self.bounds; | ||
self.backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | ||
|
||
// Layout label | ||
self.textLabelBackgroundView.frame = CGRectMake(0, | ||
self.bounds.size.height - labelHeight - inset, | ||
self.bounds.size.width, | ||
labelHeight); | ||
self.textLabelBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | ||
|
||
// Layout label background | ||
CGRect f = CGRectMake(0, | ||
0, | ||
self.textLabel.superview.bounds.size.width, | ||
self.textLabel.superview.bounds.size.height); | ||
self.textLabel.frame = CGRectInset(f, inset, 0); | ||
self.textLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters