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

The caption height is incorrect #37

Open
mdikov opened this issue Nov 19, 2012 · 0 comments
Open

The caption height is incorrect #37

mdikov opened this issue Nov 19, 2012 · 0 comments

Comments

@mdikov
Copy link

mdikov commented Nov 19, 2012

It looks like on some occasions the caption height will not be calculated properly. A simpler and safer way to calculate the size of the caption is to use [_caption sizeThatFits...]

in update caption I use this and all works fine:

           float captionWidth = _container.frame.size.width-kCaptionPadding*2;

            _caption.numberOfLines = 0;
            _caption.text = caption;
            CGSize adjustedSize = [_caption sizeThatFits:CGSizeMake(captionWidth, _container.frame.size.height)];

            NSInteger containerHeight = adjustedSize.height+kCaptionPadding*2;
            _captionContainer.frame = CGRectMake(0, -containerHeight, _container.frame.size.width, containerHeight );
            _caption.frame = CGRectMake(kCaptionPadding, kCaptionPadding, captionWidth, adjustedSize.height );

            // show caption bar
            _captionContainer.hidden = NO;
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

1 participant