From 7407f5fcf83f4a07873b995dc01912ea388237d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F=20=D0=93=D1=80=D0=B5=D1=87=D1=83?= =?UTF-8?q?=D1=85=D0=B8=D0=BD?= Date: Wed, 30 Dec 2015 18:41:34 +0300 Subject: [PATCH] [ios] Fixed coordinates cell text size. --- iphone/Maps/Classes/MWMPlacePageInfoCell.mm | 40 ++++++++++++--------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/iphone/Maps/Classes/MWMPlacePageInfoCell.mm b/iphone/Maps/Classes/MWMPlacePageInfoCell.mm index 64742601d6..3f5d9c22a8 100644 --- a/iphone/Maps/Classes/MWMPlacePageInfoCell.mm +++ b/iphone/Maps/Classes/MWMPlacePageInfoCell.mm @@ -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;