Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
下の図でマークしたように、ビュー全体ではなく、UITextView で選択したテキストの背景画像を追加したいと思います。
UITextInput プロトコルは、必要なものをすべて提供する必要があります。
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextInput_Protocol/Reference/Reference.html
具体的には:
selectedTextRange
firstRectForRange
firstRectForRange:これにより、文字の範囲をカバーする長方形がわかります。文字の範囲が複数行にまたがる場合は、繰り返し呼び出す必要があります。初めてそれはあなたに最初の四角形を与え、それがカバーする範囲を教えてくれます。次に、質問している範囲を、関心のある残りの文字になるように調整し、繰り返します。
firstRectForRange: