0

我有这样的 UITextView,:

在此处输入图像描述

我想保持 'padding-top' 和 'padding-bottom' = 20pts。我使用这个“填充”术语是因为我通常在做 CSS。

由于我在 4 英寸配置下创建了该故事板,因此当它在 3.5 英寸显示器上运行时,padding-bottom 将消失。

所以我决定先用这段代码测量 UIView 的高度:

CGFloat screenHeight = _screen.frame.size.height;
float scrollHeight = screenHeight - 40;

scrollHeight 是我期望的 UITextView 的高度。它是根据显示尺寸动态计算的,所以我希望我仍然可以在 3.5 英寸上看到 padding-bottom。

我试过这段代码来设置 UITextView 的高度,但失败了:

_textViewTerms.frame = CGRectInset(_textViewTerms.frame,0,20);

这是我的界面:

@property (strong, nonatomic) IBOutlet UIView *screen;
@property (strong, nonatomic) IBOutlet UITextView *textViewTerms;
4

0 回答 0