CGSize size = CGSizeMake(320,12); //設置最大值 nickNameLabel.numberOfLines = 1; //設置行數 CGSize labelsize = [nickNameLabel.text sizeWithFont:nickNameLabel.font constrainedToSize:size lineBreakMode:NSLineBreakByWordWrapping]; //字符串在指定字體和約束下的size [nickNameLabel setFrame:CGRectMake(nickNameLabel.frame.origin.x, nickNameLabel.frame.origin.y, labelsize.width, labelsize.height)];