У меня есть UIImageView, который имеет UITextView в пределах его границ, и я хочу изменить размер UIImageView на основе текста внутри UITextView. Как мне это сделать?Как изменить размер UIImageVIew на основе содержимого внутри UITextView
Вот что я пробовал:
- (void)textViewDidChange:(MSChatCell *)cell andText:(NSString *)text isBlue:(BOOL)blue
{
NSLog(@"changing height");
UITextView *textView;
PFImageView *chat;
if(blue){
CGRect newFrame = [text boundingRectWithSize:cell.blueText.bounds.size options: NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Arial" size:10.0],NSFontAttributeName, nil] context:nil];
cell.blueText.frame = newFrame;
cell.blueChat.frame = newFrame;
}else{
CGRect newFrame = [text boundingRectWithSize:cell.whiteText.bounds.size options: NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Arial" size:10.0],NSFontAttributeName, nil] context:nil];
cell.whiteText.frame = newFrame;
cell.whiteChat.frame = newFrame;
}
}
где cell.whiteChat
и cell.blueChat
являются UIImageViews и cell.whiteText
и cell.blueText
являются UITextViews
не CGFrame не рекомендуется? – shreyashirday
oh sorry .. Я имел в виду CGRect – Gokul