-
Notifications
You must be signed in to change notification settings - Fork 104
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
intrinsicSize not correct #14
Comments
I thought I could spend just 5 minutes fixing this but I saw the way that the label works and I think it's better if the author had a look at how best to approach the problem. I wrote a couple of tests you might find useful... - (void)test_set_text_makes_text_available
{
TOMSMorphingLabel *sut = [[TOMSMorphingLabel alloc] initWithFrame:CGRectMake(0, 0, 42, 42)];
sut.text = @"Text";
XCTAssertEqual(sut.text, @"Text");
}
- (void)test_intrinsic_size_of_target_text_should_be_the_same_as_ui_label
{
NSString *string = @"TOMSMorphingLabel rocks";
TOMSMorphingLabel *sut = [[TOMSMorphingLabel alloc] initWithFrame:CGRectMake(0, 0, 42, 42)];
sut.text = string;
UILabel *label = [[UILabel alloc] init];
label.font = sut.font;
label.text = string;
NSLog(@"normal label: %@", NSStringFromCGSize(sut.intrinsicContentSize));
NSLog(@"morphing label: %@", NSStringFromCGSize(label.intrinsicContentSize));
XCTAssertTrue(CGSizeEqualToSize(sut.intrinsicContentSize, label.intrinsicContentSize));
} |
Hi. The problem with the As a result we have the following:
For example in the TOMSMorphingLabelExample project when I add the following code to the - (void)toggleTextForLabel:(UILabel *)label
{
NSString *text = self.textValues[self.idx++];
label.text = text;
NSLog(@"text: %@, label.text: %@", text, label.text);
.... // the rest unchanged
} I get the following output on the iOS Simulator:
Note the various 'hybrid' strings which are actually combinations of the text values passed to the So we can semi-reliably read the A possible solution would be keeping an internal This approach was used in cbpowell/MarqueeLabel which provides an |
I want to self-size cells in my collection view, so I need a means of updating the cell's constraints based on the content. The content in this case is a
TOMSMorphingLabel
.It appears to report a size of
{0, 0}
regardless of what text is set onto it.This is surprising, considering it is just a UILabel subclass, right.
The text was updated successfully, but these errors were encountered: