multiple line of UILabel, is it possible?
By : user3114153
Date : March 29 2020, 07:55 AM
I hope this helps . As your working with a UIButton. You can take advantage of the label already on it, use button.titleLabel to access it. Next set button.titleLabel.minimumFontSize and button.titleLabel.font. Then set button.titleLabel.numberOfLines > 1.
|
UILabel multiple line in UITableViewCell
By : potshot
Date : March 29 2020, 07:55 AM
|
ios6 uilabel not center text aligned
By : HSN
Date : March 29 2020, 07:55 AM
seems to work fine Ok looks like turning on Tighten Letter Spacing has a different result on ios 5 and 6. I honestly cant explain why the difference but just turning this off gives the desired centering of labels for me. Just leaving this here as an answer in case anyone else makes the same silly mistake. For example: code :
lbl.adjustsLetterSpacingToFitWidth = NO;
|
UILabel sizeToFit doesn't work with autolayout ios6
By : 曹思源
Date : March 29 2020, 07:55 AM
like below fixes the issue Please note that in most cases Matt's solution works as expected. But if it doesn't work for you, please, read further. To make your label automatically resize height you need to do following: code :
self.descriptionLabel = [[UILabel alloc] init];
self.descriptionLabel.numberOfLines = 0;
self.descriptionLabel.lineBreakMode = NSLineBreakByWordWrapping;
self.descriptionLabel.preferredMaxLayoutWidth = 200;
[self.descriptionLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
[self.descriptionLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
[self.descriptionLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
[self addSubview:self.descriptionLabel];
NSArray* constrs = [NSLayoutConstraint constraintsWithVisualFormat:@"|-8-[descriptionLabel_]-8-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(descriptionLabel_)];
[self addConstraints:constrs];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-8-[descriptionLabel_]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(descriptionLabel_)]];
[self.descriptionLabel addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[descriptionLabel_(220@300)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(descriptionLabel_)]];
|
UILabel: multiple lines of text animation fade line by line
By : Dyps
Date : March 29 2020, 07:55 AM
this will help I have created a function for your request. Make sure your label have dynamic height, numberOfLines = 0 and try it ;) code :
- (void)animateLabel:(UILabel*)label withString:(NSString*)string duration:(NSTimeInterval)duration {
NSUInteger length = [string length];
NSUInteger paraStart = 0, paraEnd = 0, contentsEnd = 0;
NSMutableArray *displayedStringArray = [NSMutableArray array];
NSRange currentRange;
while (paraEnd < length) {
[string getParagraphStart:¶Start end:¶End
contentsEnd:&contentsEnd forRange:NSMakeRange(paraEnd, 0)];
currentRange = NSMakeRange(0, contentsEnd);
[displayedStringArray addObject:[string substringWithRange:currentRange]];
}
CATransition *animation = [CATransition animation];
animation.duration = duration;
animation.type = kCATransitionFade;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
__block void (^animationBlock) (int lineNumber);
__block void (^weakAnimationBlock) (int lineNumber);
animationBlock = ^void(int lineNumber){
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(duration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[label.layer addAnimation:animation forKey:@"changeTextTransition"];
label.text = displayedStringArray[lineNumber];
weakAnimationBlock = animationBlock;
__block int nextLine = lineNumber + 1;
if (nextLine < displayedStringArray.count) {
weakAnimationBlock(nextLine);
}
});
};
animationBlock(0);
}
|