删除UITextView多余的边框 [英] Remove UITextView extra border
问题描述
我做了一个UITextView
,但是有一些多余的空格:
I've made a UITextView
yet there's some unwanted spacing:
(我正在分别绘制白框).我相当确定我的坐标正确,因为如果滚动它,它会在正确的位置被切断:
(I'm drawing the white box separately). I'm fairly certain I got the coordinates right since if I scroll it gets cut off at the right places:
我怎样才能使文本向左更远地绘制,并使最顶部的位置在顶部更远?也就是说,我希望它看起来像这样:
How can I make the text be drawn further to the left, and also to have the top-most position be further on the top? That is, I'd like it to look like this:
我尝试过[[textView layer] setBorderWidth:0.0f]
,但无济于事-它已经没有边框.如果将边框宽度设置为2并设置为红色,则外观如下:
I've tried [[textView layer] setBorderWidth:0.0f]
, but to no avail - it already doesn't have a border. This is what it looks like if I set the border width to 2 and to the color red:
我很好奇额外的间距来自哪里以及如何控制它.
I'm curious where the extra spacing is coming from and how to control it.
推荐答案
以下似乎可以解决问题:
It seems that the following does the trick:
UITextView *textView = ...;
[textView setContentInset:UIEdgeInsetsMake(-10, -8, 0, 0)];
结果完全符合我的期望.由于它使用魔术数字,因此不太令人满意,因此,如果有人有更好的答案,请随时发表评论或回答.
The result is exactly as I wanted it to be. This isn't too satisfying as it uses magic numbers, so if anyone has a better answer, feel free to comment or answer.
这篇关于删除UITextView多余的边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!