uilable根据内容多少自动改变高度

//将获取的问题内容给quest_str
    NSString *quest_str = [NSString stringWithFormat:@""];
    lab_quests_content.text = quest_str;
    
    [lab_quests_content setNumberOfLines:0];
    [lab_quests_content setLineBreakMode:UILineBreakModeWordWrap];
    
    UIFont *font_lab_quest = [UIFont systemFontOfSize:13.0];
    lab_quests_content.font = font_lab_quest;
    
    CGSize size = CGSizeMake(lab_quests_content.frame.size.width, 200);
    CGSize labSize = [quest_str sizeWithFont:font_lab_quest constrainedToSize:size lineBreakMode:UILineBreakModeWordWrap];
    
    CGRect frame = lab_quests_content.frame;
    frame.size.height = labSize.height;
    lab_quests_content.frame = frame;
    
    //answer_view
    view_quests_answers.frame = CGRectMake(frame.origin.x, frame.origin.y + labSize.height + 20, view_quests_answers.frame.size.width, view_quests_answers.frame.size.height);


你可能感兴趣的:(uilable根据内容多少自动改变高度)