简体   繁体   中英

How To Resize UITextField According to the Content in iOS7?

Although i Have got many Links for how to Resize UITextField according To Content Added inside it,my TextField's is Not Growing with the Text.May be I am missing out Something. I have Also Tried this Method Which i Got While Searching For this issue,still it is not working.I know i am missing out Something.But not Getting What Exactly.

- (IBAction) textFieldDidChange: (UITextField*) textField
{
    [UIView animateWithDuration:0.1 animations:^{
        [textField invalidateIntrinsicContentSize];
    }];
}

i am Using Xcode 5.1.1 for iOS7 compatibility. Can anyone help What i am missing Out? Thanks in Advance

You can change the height of text field but you cannot use more than one line of data in text field instead you can use textview as given below:

UITextView *textView=[UITextView alloc]init];
textView.frame= CGRectMake(20,20, 455, 80);
textView.layer.cornerRadius=6;
textView.font = [UIFont systemFontOfSize:15.0];
textView.layer.borderWidth=1;
textView.layer.borderColor=[[UIColor grayColor] CGColor];
textView.textColor=[UIColor blackColor];
textView.editable=YES;
[self.view addSubView:textView];

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM