UITextView uncheck Selectable checkbox cause text

2019-08-12 01:06发布

问题:

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)