2017-06-02 11 views
-1

それは背景、矢印の方向、としたときにぼやけたのは今回が初めてのために表示されたときに問題がある私は、カスタムエディットメニューを作ってるんだ、これが私のコードカスタム[編集]メニューのiOSスウィフト

UIMenuController.shared.menuItems = textFormatEditMenu() 
    let cursorPosition = noteTextView.caretRect(for: (self.noteTextView.selectedTextRange?.start)!).origin 
    let cursorPositionInView = self.noteTextView.convert(cursorPosition, to: self.view) 
    let menuRect = CGRect(x:cursorPositionInView.x, y:cursorPositionInView.y-50, width: 0, height: 0) 

    UIMenuController.shared.setTargetRect(menuRect, in: noteTextView) 

    UIMenuController.shared.arrowDirection = .up 
    UIMenuController.shared.setMenuVisible(true, animated: true) 

です上下にスクロールすると、メニューの位置が狂ってしまいます。それで、私が欲しいのは、選択した単語の上または下にカスタム編集メニューを表示することです。

答えて

0

はあなたのメニュー項目を追加する必要がありますようだ:

let actionItem1 = UIMenuItem(title: "Action1", action: #selector(ViewController.action1(_:))) 
let actionItem2 = UIMenuItem(title: "Action2", action: #selector(ViewController.action2(_:))) 

UIMenuController.shared.menuItems = [actionItem1, actionItem2] 
関連する問題