UITextView uncheck Selectable checkbox cause text

2019-08-12 00:46发布

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

enter image description here

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?

2条回答
走好不送
2楼-- · 2019-08-12 00:57

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)
查看更多
乱世女痞
3楼-- · 2019-08-12 01:11

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

查看更多
登录 后发表回答