Comments (4)
@scalessec Hi, any reaction would be appreciated.
from toast.
I have solved this issue in version 4.0.0 in:
- (UIView *)toastViewForMessage:(NSString *)message title:(NSString *)title image:(UIImage *)image style:(CSToastStyle *)style;
The details of the change are in PR #118.
Example
I used the Example project to test the changes for DEMO button Make toast with an image
.
I modified the test code in tableView;didSelectRowAtIndexPath:
to:
// Customise the Toast via a style:
CSToastStyle *style = [[CSToastStyle alloc] initWithDefaultStyle];
style.titleAlignment = NSTextAlignmentCenter;
style.messageAlignment = NSTextAlignmentLeft;
style.horizontalPadding = 10;
style.maxWidthPercentage = 0.82;
// Make toast with a title
[self.navigationController.view makeToast:@"This is a piece of toast with a title"
duration:20.0
position:CSToastPositionTop
title:@"Toast Title"
image:nil
style:style
completion:nil];
Current situation
When running this in 4.0.0, despite setting style.titleAlignment = NSTextAlignmentCenter
the title is not centred, but left aligned:
Solution
After my code fix, the title is centred correctly:
Bonus: this fixes more
My fix also solves a padding issue in version 4.0.0.
When changing style.horizontalPadding
to 70 in the sample code from above, the wrapper clips over the display edges:
It definitely fails to comply to style.maxWidthPercentage
. It should resize the title and message labels for the larger padding. Same sample code with my fix:
Validation
Here are examples of other settings for style.titleAlignment
and style.messageAlignment
:
With an image, both title and message right aligned and padding set to 30:
from toast.
I think a method just change UIView+Toast.m line 237 expectedSizeTitle = CGSizeMake(MAX(maxSizeTitle.width, expectedSizeTitle.width), MIN(maxSizeTitle.height, expectedSizeTitle.height)); but i don't know whether it has a bad effect, you can try it.
from toast.
Hi, has this been fixed? I've integrated toast using Pods, and title alignment does not seem to do anything. I've tried left, right and centre.
from toast.
Related Issues (20)
- how to bind toast in RoboVM
- The position of activity view is not right HOT 1
- Xcode 10 error HOT 2
- Remove existing Toast HOT 1
- Problem on creating loading view with Toast
- Is there a way to block background view?
- 键盘会挡住 HOT 2
- Could not find module 'Toast_Swift' for target 'armv7-apple-ios'; found: arm64, arm64-apple-ios HOT 1
- Toast not working HOT 1
- makeToast got error HOT 1
- Toast is always showing at bottom
- can you add a setting accessibility?
- feature request: verticalOffset(s)
- Hello
- Is it possible to change the size (width height) of the toast?
- how to change activity color
- Privacy manifest required by Apple HOT 1
- Toast.podspec HOT 4
- how can i show a toast over keyboard? HOT 1
- about the PrivacyInfo.xcprivacy HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from toast.