6

Marking text in a UITextView, but for some reason it's refusing to accept anything I give it with setMarkedTextStyle. -markedTextStyle always returns nil, and the marked text always looks the same (blue background and maintains text color).

[_taggedUsersView setMarkedTextStyle:@{UITextInputTextColorKey: [UIColor whiteColor], UITextInputTextBackgroundColorKey: [UIColor tranceLinkBlue], UITextInputTextFontKey: [UIFont fontWithName:@"HelveticaNeue-Medium" size:14.0]}];

Tried doing this both when I create the textview, right before marking text and right after. But it still maintains the default style, and returns nil for the style.

Christian A. Strømmen
  • 3,115
  • 2
  • 24
  • 43

3 Answers3

2

After a lot of testing the only thing I can say is that it is a bug in the SDK. Setting markedTextStyle property has no effect and getter returns always nil.

This comes against what we can read in documentation:

markedTextStyle

A dictionary of attributes that describes how marked text should be drawn.

I reported it to Apple as a bug (Bug ID - 17914881).

Rafa de King
  • 38,474
  • 23
  • 108
  • 138
  • UITextField is equally affected by this bug. I've reported rdar://30208223 / http://openradar.appspot.com/30208223). Did you ever get a response to your report? – Ortwin Gentz Jan 26 '17 at 17:00
  • Still not fixed I believe Nothing happens when I set it on iOS 13 – Asad Khan Nov 05 '19 at 14:34
0

I think you want to use attributed text property instead of markedtextstyle (if I understand your question correctly)

https://developer.apple.com/library/ios/documentation/uikit/reference/uitextview_class/Reference/UITextView.html

How can I set the color and alignment of attributed text in a UITextView in iOS 7?

Community
  • 1
  • 1
MobileMon
  • 7,847
  • 5
  • 49
  • 69
0

Do you want to change the selectedText or the markedText property?

The later will only for Chinese/Japanese writing so maybe you should try modifying highlightedTextColor instead.

Rivera
  • 10,444
  • 3
  • 53
  • 100