Apple Swift Logo

Swift Tips #1: Extra padding problem on UITextView?

Sometimes when you integrate a design, you need things to be square, everything aligned: buttons, title, images, textView…

But wait, what’s that extra padding on the UITextView?

UITextView Animation

You may have tried to print the contentOffset or contentInset without success. That’s not it. However, all your problems can be solved in one line, and here it is:

// magic line for a UITextView named textView
textView.textContainer.lineFragmentPadding = 0

I wouldn’t call it exactly straight forward, so this is a memo for me and tip for you :)

Leave a Comment

You want to leave a comment? Sweet! Please do so, but keep in mind that all comments are moderated and rel="nofollow" is in use. So no fake comment or advertisement will be approved. And don't worry, your email address won't be published. Thanks!

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>