ios - How do I get the text to align to the top in UITextView? -


running xcode 8.3.3 have uitextview fills entire view. however, text not align top has more 80 points padding @ top - see attached screenshot.

i have worked constraints, alignment , searched documentation cannot see how resolve issue.

any pointers appreciated.

enter image description here

okay based on query had tried 1 solution please have @

1) here first output space getting default

i used following code show happening there, using textview covers full screen top bottom storyboard

 //outlet  @iboutlet weak var mytextview: uitextview!   //call function , assign textview  override func viewwillappear(_ animated: bool) {         adjustcontentsize(tv: mytextview)     }      //this add respected boundaries textview content      func adjustcontentsize(tv: uitextview){         let deadspace = tv.bounds.size.height - tv.contentsize.height         let inset = max(0, deadspace/2.0)          tv.contentinset = uiedgeinsetsmake(inset, tv.contentinset.left, inset, tv.contentinset.right)     }      //will check when value changed     func textviewdidchange(_ textview: uitextview) {         self.adjustcontentsize(tv: textview)     } 

--simulator output

enter image description here

2) expected output

--code

//outlet  @iboutlet weak var mytextview: uitextview!   //call function , assign textview  override func viewwillappear(_ animated: bool) {         adjustcontentsize(tv: mytextview)     }  //this add respected boundaries textview content      func adjustcontentsize(tv: uitextview){         tv.contentinset = uiedgeinsetsmake(0, tv.contentinset.left, 0,tv.contentinset.right)     }      //will check when value changed     func textviewdidchange(_ textview: uitextview) {         self.adjustcontentsize(tv: textview)     } 

--expected output

enter image description here

hope helps :)


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -