我有一个 UITextView 作为 UIView 的子视图。我已将 UIView 放在屏幕底部。视图控制器有 UITabViewController。我给了 UIView 的帧大小,如下所示,
toolBarView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 330, 320, 40)];
[self.view addSubview: toolBarView1];
TextView1 = [[UITextView alloc] initWithFrame:CGRectMake(35, 7.5, 210, 25)];
textViewImageView1 = [[UIImageView alloc]initWithFrame: CGRectMake(0, 0, 210, 25)];
[TextView1 addSubview: textViewImageView1];
[toolBarView1 addSubview: TextView1];
我想根据 UITextView 内部的文本增加 UITextView 的高度。我已经使用了下面的代码,
CGRect frame = messageTextView1.frame;
frame.size.height = messageTextView1.contentSize.height;
NSLog(@"TextViewHeight With Texts : %f", frame.size.height);
int height = frame.size.height;
NSLog(@"TextViewHeight With Texts : %d", height);
height = height + 10;
NSLog(@"Height Plus 10 : %d", height);
height = 370 - height;
NSLog(@"ToolBarView1 Y axis : %d", height);
messageTextView1.frame = frame;
textViewImageView1.frame = CGRectMake(0, 0, messageTextView1.frame.size.width, messageTextView1.frame.size.height);
toolBarView1.frame = CGRectMake(0, height, 320, messageTextView1.frame.size.height+10);
我想将 UIView 和 UITextView 放在屏幕本身的底部,但我想根据 UITextview 高度增加 UIView 和 UITextview 的高度以及 UIView 的 Y 轴。谁能帮我做到这一点?提前致谢。