Skip to content

Instantly share code, notes, and snippets.

@enormego
Created June 2, 2009 20:02
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save enormego/122538 to your computer and use it in GitHub Desktop.
Save enormego/122538 to your computer and use it in GitHub Desktop.
//
// EGOTitledTableViewCell.h
// EGOClasses
//
// Created by Shaun Harrison on 6/2/09.
// Copyright 2009 enormego. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface EGOTitledTableViewCell : UITableViewCell {
@private
UILabel* titleLabel;
UILabel* textLabel;
}
@property(nonatomic,copy) NSString* title;
@property(nonatomic,readonly) UILabel* titleLabel;
@property(nonatomic,readonly) UILabel* textLabel;
@end
//
// EGOTitledTableViewCell.m
// EGOClasses
//
// Created by Shaun Harrison on 6/2/09.
// Copyright 2009 enormego. All rights reserved.
//
#import "EGOTitledTableViewCell.h"
@implementation EGOTitledTableViewCell
@synthesize titleLabel, textLabel;
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 44.0f) reuseIdentifier:reuseIdentifier]) {
float titleWidth = floor(self.contentView.frame.size.width * .30);
float textWidth = self.contentView.frame.size.width - titleWidth - 10.0f;
titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, titleWidth, self.contentView.frame.size.height)];
titleLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight;
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.highlightedTextColor = [UIColor whiteColor];
titleLabel.font = [UIFont boldSystemFontOfSize:13.0f];
titleLabel.textColor = [UIColor grayColor];
titleLabel.textAlignment = UITextAlignmentRight;
textLabel = [[UILabel alloc] initWithFrame:CGRectMake(titleWidth+10.0f, 0.0f, textWidth, self.contentView.frame.size.height)];
textLabel.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
textLabel.backgroundColor = [UIColor clearColor];
textLabel.highlightedTextColor = [UIColor whiteColor];
textLabel.font = [UIFont boldSystemFontOfSize:17.0f];
[self.contentView addSubview:titleLabel];
[self.contentView addSubview:textLabel];
}
return self;
}
- (void)setText:(NSString*)text {
textLabel.text = text;
}
- (NSString*)text {
return textLabel.text;
}
- (void)setTitle:(NSString*)title {
titleLabel.text = title;
}
- (NSString*)title {
return titleLabel.text;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)dealloc {
[titleLabel release];
[textLabel release];
[super dealloc];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment