Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6388669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:18:27+00:00 2026-05-25T03:18:27+00:00

I wondered how to set the UITextView so that the text inside aligns to

  • 0

I wondered how to set the UITextView so that the text inside aligns to the bottom? Like, if you start typing, you will always type in the lowest row?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:18:28+00:00Added an answer on May 25, 2026 at 3:18 am

    I don’t believe there is a built-in way to vertically align the text in a UITextView, but you should be able to use the contentOffset property of the UITextView class to accomplish this. See this blog post for more details:

    http://imagineric.ericd.net/2011/03/10/ios-vertical-aligning-text-in-a-uitextview/

    Update: since the above link appears to be dead, I used the Wayback Machine to retrieve an archived copy and have pasted the text of the article below.

    The default and expected behavior of a UITextView (multi-line text) out of the box in iOS is to align the text top left in it’s container. That works well most of the time. However I recently had need to either center the text vertically within the control or have all the text align to the bottom of the control.

    You can add an observer to the control and when it’s content size changes (text is set), fire a method. The method can then handle how the text is actually positioned in the control. If it doesn’t make sense to do the alignment, it will default to the normal behavior of the control (top vertical alignment).

    Here we go:

    - (void) viewDidLoad {
       [textField addObserver:self forKeyPath:@"contentSize" options:(NSKeyValueObservingOptionNew) context:NULL];
       [super viewDidLoad];
    }
    
    -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
       UITextView *tv = object;
       //Center vertical alignment
       //CGFloat topCorrect = ([tv bounds].size.height - [tv contentSize].height * [tv zoomScale])/2.0;
       //topCorrect = ( topCorrect < 0.0 ? 0.0 : topCorrect );
       //tv.contentOffset = (CGPoint){.x = 0, .y = -topCorrect};
    
       //Bottom vertical alignment
       CGFloat topCorrect = ([tv bounds].size.height - [tv contentSize].height);
        topCorrect = (topCorrect <0.0 ? 0.0 : topCorrect);
        tv.contentOffset = (CGPoint){.x = 0, .y = -topCorrect};
    }
    

    You can decide which you’d like to use, or flush the method out to take an argument for which type of vertical alignment you’d like to use. This works quite well and it would have been nice if the properties were built into the control to begin with.

    If you can use it, enjoy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I noticed that i can set a return type on a function to 'Void'
This is something I've always wondered about. I understand that horizontal scaling is about
I always wondered why I have to manually set the JAVA_HOME environment variable after
I wondered if there is a programming language which compiles to machine code/binary that
I've always wondered this - why can't you declare variables after a case label
I have always wondered how people update a previous line in a command line.
I have always wondered WHaT tHE HecK?!? is the difference between JScript and JavaScript.
I've always wondered why the C++ Standard library has instantiated basic_[io]stream and all its
I've used emacs for decades and always wondered, but kept on coding, if there
I can set up an autofilter using pyWin32, but I wondered if it's possible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.