1

How to make a UITextView to be filled with text starting from bottom edge, if it has unchangeable height?

UPD: The text in UITextView should be shown on the in the bottom despite the UITextView's size.

Yevheniia Zelenska
  • 357
  • 1
  • 5
  • 13
  • 2
    can you make your question clear ? i think you are asking like [this](http://stackoverflow.com/questions/19065693/how-to-set-content-inset-for-uitextview-in-ios7/19065802#19065802) – Muruganandham K Jan 16 '14 at 13:32
  • If you could attach a diagram or sample of what you want it would be easier to answer your question. – fatuous.logic Jan 16 '14 at 13:53

3 Answers3

1

In your textView delegate:

    - (void)textViewDidChange:(UITextView *)textView {
        UIEdgeInsets inset = UIEdgeInsetsZero;
        inset.top = textView.bounds.size.height-textView.contentSize.height;
        textView.contentInset = inset;
    }
foundry
  • 31,615
  • 9
  • 90
  • 125
1

This worked for me:

Set self as the UITextViewDelegate.

-(void)resizeToContent
{
    if (self.alignBottomUp)
    {
        UIEdgeInsets inset = UIEdgeInsetsZero;
        CGFloat height = ceilf([self sizeThatFits:self.bounds.size].height);
        inset.top = self.bounds.size.height - height;
        self.textContainerInset = inset;
    }
}


-(void)setAlignBottomUp:(BOOL)value
{
    if (value != _alignBottomUp)
    {
        _alignBottomUp = value;
        [self resizeToContent];
    }
}

- (void)textViewDidChange:(UITextView *)textView
{
    if (self.alignBottomUp)
    {
        [self resizeToContent];
    }
}

See also: UITextView doesn't update its contentSize

Community
  • 1
  • 1
iPhoneDev
  • 11
  • 2
0

If I understand you correctly you are trying to align your text to the bottom of the UITextView. As far as I know there is no built in way to do this so you'll have to write it by yourself. Take a look at the answer to this question which describes one possible way of doing this.

Community
  • 1
  • 1
Gad
  • 2,867
  • 25
  • 35