Removing padding from UITextView

A while ago I faced annoying “problem” related to UITextView. Apparently it has default padding which in some cases is really unnecessary and while  there seems to be no perfect solution there is one workaround we can use to get rid of that nasty padding – negative contentInset.

UITextView *tv = [[UITextView alloc] init];
tv.font = [UIFont fontWithName:@"Arial" size:18];
tv.contentInset = UIEdgeInsetsMake(-11,-8,0,0);

As you can see quite clearly (I was too lazy to draw some guidelines) in image bellow results are satisfying, but, unfortunately, top padding is related to the size of font we’re using, so some adjusting of top edge inset may be required.

UITextView padding problem

UITextView padding problem

Tags: ,

17 responses

  1. Posted January 19, 2010 at 09:58 | Permalink

    Why would you ever want to remove padding from things?… Padding is good.

    • Foobar Pig
      Posted February 11, 2010 at 14:30 | Permalink

      Padding is good when you actually need it to exist and in my case I didn’t :)

  2. Posted May 8, 2010 at 19:34 | Permalink

    Thanks for your post. Very useful Needed to remove padding as you did and your example works perfectly.

    Andy

  3. Mohan
    Posted July 2, 2010 at 07:00 | Permalink

    Thanks very much for the post, it really helped and saved me a lot of time,
    Thanks once again. good work.

  4. Posted March 30, 2011 at 03:33 | Permalink

    Zune and iPod: Most people compare the Zune to the Touch, but after seeing how slim and surprisingly small and light it is, I consider it to be a rather unique hybrid that combines qualities of both the Touch and the Nano. It’s very colorful and lovely OLED screen is slightly smaller than the touch screen, but the player itself feels quite a bit smaller and lighter. It weighs about 2/3 as much, and is noticeably smaller in width and height, while being just a hair thicker.

  5. Posted May 14, 2011 at 05:12 | Permalink

    I love the fact that flexible OLEDs have a faster response time than LEDs!

  6. Posted May 16, 2011 at 17:50 | Permalink

    Aloha, great internet site! You have helped me out with my undertaking and this rescued my week-end :) My company will be content this tuesday!

  7. Posted May 20, 2011 at 12:43 | Permalink

    It’s arduous to find educated individuals on this matter, however you sound like you recognize what you’re speaking about! Thanks

  8. Posted May 20, 2011 at 15:25 | Permalink

    The subsequent time I read a weblog, I hope that it doesnt disappoint me as a lot as this one. I mean, I know it was my option to read, but I really thought youd have something attention-grabbing to say. All I hear is a bunch of whining about something that you possibly can repair should you werent too busy on the lookout for attention.

  9. Posted May 20, 2011 at 21:07 | Permalink

    That is the appropriate blog for anybody who desires to seek out out about this topic. You understand so much its almost laborious to argue with you (not that I actually would want…HaHa). You undoubtedly put a new spin on a topic thats been written about for years. Nice stuff, simply nice!

  10. Posted June 17, 2011 at 22:33 | Permalink

    Thanks for the tip, it it very useful. A bit tricky but useful ;-)

  11. Posted July 3, 2011 at 18:01 | Permalink

    Great article, nicely written. Deserves some +1 :) Thanks again.

  12. Posted August 2, 2011 at 16:31 | Permalink

    Jamais lol Sinon quelqu’un aurai le lien de la page qui permet de mettre une petite image a la place de forme geometrique nous representent sur la droite

  13. Posted April 17, 2012 at 13:29 | Permalink

    “Great, thanks for truly sharing your blog post.Many thanks again. Wonderful.”

  14. Posted December 9, 2012 at 19:07 | Permalink

    If you desire to take a great deal from this article then you have to apply such techniques to your won web site.|

  15. Posted January 7, 2013 at 19:50 | Permalink

    The new apps are pretty cool, but the real world add-ons for the phones are even more impressive. I got my kid one of those phone controlled helicopters for Christmas, and I can’t stop playing with it!

  16. Burt Grassia
    Posted January 19, 2013 at 19:57 | Permalink

    I’m nonetheless learning from you, however I’m bettering myself. I certainly love reading all the things that’s written in your blog.Hold the stories coming. I cherished it!

Leave a Reply