UITextView uncheck Selectable checkbox cause text issues in runtime

二次信任 提交于 2019-12-11 06:13:42

问题


Using text view in storyboard you can make it not editable or not selectable next to Behavior caption or vice versa:

Seems options looks very promising and it works good for editable option. But when I uncheck selectable checkbox it cause some issues with font and text in runtime. So let's say that I set font to Helvetica-Bold and set color Red (which are not default settings for text view) and then uncheck selectable box like on image above. Next let me add some code to viewDidLoad:

self.theSameTextViewIamTalkingAbout.text = @"some text";

So when I am running my application I see that text change back to the default font and to the black color which is the default color.

I am not sure if this checkbox reset text view to the default appearance settings, but it changes text color and font text as you can see on my video as well:

HERE IS MY VIDEO LINK

My question also how can I make it not selectable?


回答1:


Try to change font and font color in code. It's help for me.




回答2:


Programmatically set isSelectable -> true and set font what ever you want

Swift 3.0 and Xcode 8

self.txtView?.isSelectable = true

self.txtView?.font =  UIFont (name: "Helvetica Neue", size: 16)


来源:https://stackoverflow.com/questions/27635439/uitextview-uncheck-selectable-checkbox-cause-text-issues-in-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!