UITextView not saving markedTextStyle (UITextInput protocol)
Asked Answered
J

3

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.

Jacobin answered 26/7, 2014 at 22:45 Comment(5)
Long shot, but have you tried self.taggedUsersView?Ormuz
If you're running iOS 8, that can be a problem as it is now deprecated: Deprecated in iOS 8.0.Lancers
What is deprecated? Both markedTextStyle and setMarkedTextRange isn't deprecated in the iOS 8 docs I'm looking at now.Marauding
#8067128Oleate
Not the same issue Kumar. My markedText is not nil, just the style.Marauding
J
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).

Joub answered 5/8, 2014 at 11:10 Comment(2)
UITextField is equally affected by this bug. I've reported rdar://30208223 / openradar.appspot.com/30208223). Did you ever get a response to your report?Thermography
Still not fixed I believe Nothing happens when I set it on iOS 13Stigmatize
T
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?

Treaty answered 29/7, 2014 at 19:30 Comment(1)
Actually the marked text style is separate from this. I'm already using attributed text in the textview, but the marked style is independent of that.Marauding
W
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.

Wilkinson answered 5/8, 2014 at 9:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.