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

Ensure toast still fits on screen after rotation #11 #2

Open
wving5 opened this issue Jun 15, 2019 · 0 comments
Open

Ensure toast still fits on screen after rotation #11 #2

wving5 opened this issue Jun 15, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@wving5
Copy link
Owner

wving5 commented Jun 15, 2019

scalessec#11

        // size the message label according to the length of the text
        CGSize maxSizeMessage = CGSizeMake((self.bounds.size.width * CSToastMaxWidth) - imageWidth, self.bounds.size.height * CSToastMaxHeight);

+        //make sure that if we rotate the message will still fit on the screen
+       CGFloat rotatedMaxMessageWidth = (self.bounds.size.height * CSToastMaxWidth) - imageWidth;
+        if (maxSizeMessage.width > rotatedMaxMessageWidth) maxSizeMessage.width = rotatedMaxMessageWidth;

        CGSize expectedSizeMessage = [message sizeWithFont:messageLabel.font constrainedToSize:maxSizeMessage lineBreakMode:messageLabel.lineBreakMode]; 
        messageLabel.frame = CGRectMake(0.0, 0.0, expectedSizeMessage.width, expectedSizeMessage.height);
    }
@wving5 wving5 added the enhancement New feature or request label Jun 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant