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:
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.
Have you tried experimenting with textContainerInset?
According to the docs at developer.apple.com , "This property provides text margins for text laid out in the text view." This is new in iOS 7.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.