objective c - How to tell when a UILabel will be truncated an/or its line break position will change -
I have a multi-line Example 1: Decrease in width Separate line leads to break points Example 2: Decrease width decrease Leads Example 3: The cut in width leads to both punching and a different line break position Example 4 : There is no effect on cutting or breaking position in width This change in formatting is quite confusing So, I intend to mask it behind some animation (possibly a fade / fade out). However, the first hurdle when I need to do this. Whenever the label is re-shaped I still do not want to apply on the animation - only when it will change the transition or line break situation. How can I test it? Examples 1, 2, and 3 should be yes for example, but none for example. Note: Changing the shape will never change the number of rows in my example. Note 2: If anyone has some better tags related to text formatting, then I would love to know - feel free to edit Note 3: If you are interested in completing this behavior, then try Apple's Mail.app on the iPhone when an Inbox view is displayed on the iPhone and in the form of Fade-In / Outline Line It wraps again and / or trunkets clock (but it does not need when). You can change the size of the label to display a specific returns the string size if it was sung with specified obstacles. So what you want is More useful OK, another way of doing whatever you want : 1) Create 2 2) Set This will give you similar results to Mail.app . UILabel (
numberOfLines = 0) . Its width can change on runtime, and sometimes it leads to spraying and / or re-rapping. In some instances, this is the best thing:
NSString example Know For example, you can use that one:
- (CGSize) sizeWithFont: (UIFont *) font constrainedToSize: (CGSize) size lineBreakMode: (UILineBreakMode) lineBreakMode
to get CGSize for a particular string and check that it is not large, then
UILabel Size:
UILabel * label; CGSize sizeNeeded = [label.text sizeWithFont: label.font constrainedToSize: CGSizeMake (label.bounds.size.width, MAXFLOAT)]; If (sizeNeeded.height> gt; label.bounds.size.height) {NSLog (@ "string has been cut"); }
NSString methods you can find here:
UILabel with the same properties, but the second one (
label2 ) with another
width Will happen.
alpha
label2 to
0.0 in non-editing mode. 3) When editing mode starts making such an animation:
// label1.alpha == 1.0, label2.alpha == 0.0 {[UIView animateWithDuration : 0.5 Animation: ^ {label1.alpha = 0.0; Label2.alpha = 1.0; }]; 4) When editing mode ends:
{[UIView animateWithDuration: 0.5 Animation: ^ {label1.alpha = 1.0; Label2.alpha = 0.0; }];
Comments
Post a Comment