swift - Rotating UITextView programmatically -


there weird problem, if create uitextview , rotate right after creating it, lines or characters not visible! try this:

mytextview.font = uifont.boldsystemfontofsize(20) mytextview.text = "hello world wht hell\nhello mrs lorem ipum!" let maxsize = cgsizemake(700, 700) let frame = mytextview.sizethatfits(maxsize) mytextview.frame = cgrectmake(200, 200, frame.width, frame.height)      view.addsubview(mytextview) mytextview.transform = cgaffinetransformmakerotation(cgfloat(m_pi_2)) 

result: enter image description here

you see? of lost! if remove mytextview.transform = cgaffinetransformmakerotation(cgfloat(m_pi_2)) , run through button it's fine:

enter image description here

you can view code on git: https://github.com/maysamsh/rotatetextview

as workaround, try set uitextview in simple uiview, , rotate uiview.

it should because way, uitextview should react it's not rotated (so can set inset constraints superview)

then have care form of superview.

other solution

mytextview.font = uifont.boldsystemfontofsize(20) mytextview.text = "hello world wht hell\nhello mrs lorem ipum!" let maxsize = cgsizemake(700, 700) let frame = mytextview.sizethatfits(maxsize) mytextview.frame = cgrectmake(200, 200, frame.width, frame.height)      view.addsubview(mytextview) let delaytime = dispatch_time(dispatch_time_now, int64(0.1 * double(nsec_per_sec))) dispatch_after(delaytime, dispatch_get_main_queue()) {       mytextview.transform = cgaffinetransformmakerotation(cgfloat(m_pi_2)) } 

a bit dirty, should work, user might see small clipping, shouldn't see it.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -