Forgotten file to previous commit.

This commit is contained in:
vng 2012-10-24 23:43:42 +03:00 committed by Alex Zolotarev
parent dc293f272a
commit 4695fd10ed

View file

@ -8,21 +8,28 @@
- (id)initWithReuseIdentifier:(NSString *)identifier
{
self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
self = [super initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
if (self)
{
// Fonts and sizes are hard-coded because they can't be easily retrieved
UIFont * large = [UIFont fontWithName:@"Helvetica-Bold" size:[UIFont labelFontSize] + 1];
UIFont * small = [UIFont fontWithName:@"Helvetica" size:[UIFont systemFontSize]];
bmName = [[[UILabel alloc] init] autorelease];
bmName.font = large;
bmDistance = [[[UILabel alloc] init] autorelease];
bmDistance.font = small;
bmDistance.textColor = [UIColor grayColor];
bmDistance.textAlignment = UITextAlignmentRight;
// There is a hack below to get standart fonts and colors.
self.textLabel.text = @"tmpText";
self.detailTextLabel.text = @"tmpText";
[super layoutSubviews];
bmName.font = self.textLabel.font;
bmName.textColor = self.textLabel.textColor;
bmDistance.font = self.detailTextLabel.font;
bmDistance.textColor = self.detailTextLabel.textColor;
self.detailTextLabel.text = nil;
self.textLabel.text = nil;
[self.contentView addSubview:bmName];
[self.contentView addSubview:bmDistance];
}
@ -35,9 +42,17 @@
CGRect r = self.contentView.bounds;
// Leave some experimentally choosen paddings
CGFloat const KPaddingX = 10.0;
CGFloat const KPaddingX = 9.0;
CGFloat const KPaddingBottom = 1.0;
if (self.imageView.image)
{
CGRect const imgRect = self.imageView.frame;
CGFloat const imgPadding = imgRect.size.width + imgRect.origin.x;
r.origin.x += imgPadding;
r.size.width -= imgPadding;
}
r.origin.x += KPaddingX;
r.size.width -= 2 * KPaddingX;
r.size.height -= KPaddingBottom;
@ -45,7 +60,7 @@
// Labels on the right should always fit and be visible, but not more than half of the cell
CGFloat const w = r.size.width;
CGFloat const h = r.size.height;
CGFloat xDelim = (int)(r.origin.x + w / 2);
if (bmDistance.text.length)
{
@ -57,7 +72,7 @@
{
xDelim = r.origin.x + w - KPaddingX;
}
bmName.frame = CGRectMake(r.origin.x, r.origin.y, xDelim - r.origin.x, h);
bmDistance.frame = CGRectMake(xDelim, r.origin.y, r.origin.x + w - xDelim, h);
}