[ios] Fixed coordinates cell text size.

This commit is contained in:
Илья Гречухин 2015-12-30 18:41:34 +03:00 committed by Sergey Yershov
parent 64c717e8b1
commit 7407f5fcf8

View file

@ -26,7 +26,7 @@
{
[super awakeFromNib];
if ([self.textContainer isKindOfClass:[UITextView class]])
[self.textContainer setTextContainerInset:{.top = 12, 0, 0, 0}];
[(UITextView *)self.textContainer setTextContainerInset:{.top = 12, 0, 0, 0}];
}
- (void)configureWithType:(MWMPlacePageMetadataType)type info:(NSString *)info;
@ -70,27 +70,33 @@
[UIImage imageNamed:[NSString stringWithFormat:@"%@%@", @"ic_placepage_", typeName]];
self.type = type;
self.icon.image = image;
if ([self.textContainer isKindOfClass:[UITextView class]])
{
[self.textContainer
setAttributedText:[[NSAttributedString alloc]
initWithString:info
attributes:@{NSFontAttributeName : [UIFont regular17]}]];
self.icon.mwm_coloring = MWMImageColoringBlue;
}
else
{
[self.textContainer setText:info];
self.icon.mwm_coloring = MWMImageColoringBlack;
}
self.icon.mwm_coloring = [self.textContainer isKindOfClass:[UITextView class]] ? MWMImageColoringBlue : MWMImageColoringBlack;
[self changeText:info];
UILongPressGestureRecognizer * longTap =
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTap:)];
longTap.minimumPressDuration = 0.3;
[self.upperButton addGestureRecognizer:longTap];
}
- (void)changeText:(NSString *)text
{
if ([self.textContainer isKindOfClass:[UITextView class]])
{
UITextView * tv = (UITextView *)self.textContainer;
[tv setAttributedText:[[NSAttributedString alloc]
initWithString:text
attributes:@{NSFontAttributeName : [UIFont regular16]}]];
}
else
{
UILabel * lb = (UILabel *)self.textContainer;
[lb setText:text];
[lb sizeToIntegralFit];
CGFloat const trailingOffset = self.width - lb.maxX;
lb.font = trailingOffset < 32 ? [UIFont regular15] : [UIFont regular16];
}
}
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
{
return YES;
@ -113,7 +119,7 @@
case MWMPlacePageMetadataTypeCoordinate:
[[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatToggleCoordinates)];
[self.currentEntity toggleCoordinateSystem];
[self.textContainer setText:[self.currentEntity getFeatureValue:MWMPlacePageMetadataTypeCoordinate]];
[self changeText:[self.currentEntity getFeatureValue:MWMPlacePageMetadataTypeCoordinate]];
break;
default:
break;