1
是否可以擁有一個多行UILabel,可以自動調整UIFont大小以適應UILabel的大小?如果不是,那麼實現這一目標的最佳方式是什麼?我不想調整UILabel/UITextView的幀大小。到目前爲止,我一直在做這樣的:多行自動調整文本UILabel
int currentFontSize = 18;
UIFont *currentFont = [UIFont fontWithName:kProximaNovaBold size:currentFontSize];
CGSize storyTitleSize = [storyTitle sizeWithFont:currentFont constrainedToSize:self.newsfeedStoryTitle_.frameSize];
while (storyTitleSize.height >= self.newsfeedStoryTitle_.frameHeight){
currentFontSize--;
currentFont = [UIFont fontWithName:kProximaNovaBold size:currentFontSize];
storyTitleSize = [storyTitle sizeWithFont:currentFont constrainedToSize:self.newsfeedStoryTitle_.frameSize];
}
[self.newsfeedStoryTitle_ setFont:currentFont];
[self.newsfeedStoryTitle_ setText:storyTitle];