Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong popup height when using attributed subtitle string #63

Closed
tvlc opened this issue Sep 2, 2017 · 5 comments
Closed

Wrong popup height when using attributed subtitle string #63

tvlc opened this issue Sep 2, 2017 · 5 comments

Comments

@tvlc
Copy link

tvlc commented Sep 2, 2017

Hi, there is a bug in calculation of popup height when using attributed string as a subtitle, see scrennshots.

popup

attrstring

Atributes used:

`

NSMutableParagraphStyle *attributedStringParagraphStyleTitle = [[NSParagraphStyle defaultParagraphStyle]mutableCopy];
attributedStringParagraphStyleTitle.alignment = NSTextAlignmentCenter;
attributedStringParagraphStyleTitle.paragraphSpacing = 6.0;

NSMutableParagraphStyle *attributedStringParagraphStyleSubtitle = [[NSParagraphStyle defaultParagraphStyle]mutableCopy];
attributedStringParagraphStyleSubtitle.alignment = NSTextAlignmentCenter;
attributedStringParagraphStyleSubtitle.paragraphSpacing = 12.0;

NSMutableParagraphStyle *attributedStringParagraphStyle = [[NSParagraphStyle defaultParagraphStyle]mutableCopy];
attributedStringParagraphStyle.alignment = NSTextAlignmentCenter;
attributedStringParagraphStyleSubtitle.paragraphSpacing = 3.0;

NSString *strKey  = annotation.featurePoint.featureKey;
NSDictionary *attrKey = @{ NSForegroundColorAttributeName:ansColorBlueLagoon,
                           NSParagraphStyleAttributeName:attributedStringParagraphStyleTitle,
                           NSFontAttributeName:[UIFont fontWithName:@"Futura-Bold" size:18.0] };    // [UIFont boldSystemFontOfSize:18.0f]

NSString *strName = annotation.featurePoint.featureName;
NSDictionary *attrName = @{ NSForegroundColorAttributeName:ansColorSapphire,
                            NSParagraphStyleAttributeName:attributedStringParagraphStyleSubtitle,
                            NSFontAttributeName:[UIFont fontWithName:@"Futura-Bold" size:16.0] };    // [UIFont boldSystemFontOfSize:18.0f]

NSString *strFir  = annotation.featurePoint.featureFIR";
NSDictionary *attrFir  = @{ NSForegroundColorAttributeName:ansColorSapphire,
                            NSParagraphStyleAttributeName:attributedStringParagraphStyle,
                            NSFontAttributeName:[UIFont fontWithName:@"Futura-Bold" size:16.0] };    // [UIFont boldSystemFontOfSize:18.0f]

NSString *strCoordinate = annotation.featurePoint.featureCoordinate;
NSDictionary *attrCoordinate = @{ NSForegroundColorAttributeName:ansColorCelurean,
                                  NSParagraphStyleAttributeName:attributedStringParagraphStyle,
                                  NSFontAttributeName:[UIFont fontWithName:@"Futura-Bold" size:14.0] };    // [UIFont boldSystemFontOfSize:18.0f]

NSAttributedString *attribText = [NSAttributedString rz_attributedStringWithStringsAndAttributes:
                                  [NSString stringWithFormat:@"%@\n",strKey],attrKey,
                                  [NSString stringWithFormat:@"%@\n",strName],attrName,
                                  [NSString stringWithFormat:@"FIR: %@\n",strFir],attrFir,
                                  [NSString stringWithFormat:@"Lat/Lon: %@",strCoordinate],attrCoordinate,
                                  nil];

`

@nimati
Copy link
Owner

nimati commented Sep 7, 2017

Hey @tvlc, Thanks for using FCAlertView. Will look into this. @digitalcatnip Would you mind taking a look at what might be causing this. Thanks!

@digitalcatnip
Copy link
Contributor

Sorry, just saw this - I will take a look when I have a chance!

@tvlc
Copy link
Author

tvlc commented Dec 26, 2017

Any progress? See three dots added at the end of the string, when the string has been truncated and missing last line of the attributed text

@tvlc
Copy link
Author

tvlc commented Mar 17, 2018

@digitalcatnip Have you already a chance to look at it?

@tvlc
Copy link
Author

tvlc commented Jun 17, 2018

I found a bug in implementation of drawRect method - it does not properly calculate the bounding box size for attributed subtitle.
Proposal for solution:

    CGSize boundingBox;
    if (descriptionLabel.attributedText == nil) {
        boundingBox = [descriptionLabel.text boundingRectWithSize:constraint
                                                             options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading
                                                          attributes:@{NSFontAttributeName:descriptionLabel.font}
                                                             context:context].size;
    } else {
        boundingBox = [descriptionLabel.attributedText boundingRectWithSize:constraint
                                                                           options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading
                                                                           context:context].size;
    }

@tvlc tvlc closed this as completed Jun 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants