I use UIMenuItem and UIMenuController to add selection to a UITextView so that the user can change the background color of the selected text, as shown in the figures below:
- Installed text in a
UITextView with the highlight function available to the user:

- Selected text in a
UITextView with a new background color selected by the user after clicking on highlight : 
In iOS 7 , the following code is ideal for this task. :
- (void)viewDidLoad { [super viewDidLoad]; UIMenuItem *highlightMenuItem = [[UIMenuItem alloc] initWithTitle:@"Highlight" action:@selector(highlight)]; [[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObject:highlightMenuItem]]; } - (void)highlight { NSRange selectedTextRange = self.textView.selectedRange; [attributedString addAttribute:NSBackgroundColorAttributeName value:[UIColor redColor] range:selectedTextRange];
But in iOS 8 , text selection jumps over. When I use the select function from UIMenuItem and UIMenuController , it also jumps to another UITextView offset.
How to solve this problem in iOS 8 ?
source share