mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			16 lines
		
	
	
		
			656 B
		
	
	
	
		
			Swift
		
	
			
		
		
	
	
			16 lines
		
	
	
		
			656 B
		
	
	
	
		
			Swift
		
	
| 
 | |
| extension UILabel {
 | |
|     
 | |
|     func characterIndex(for point: CGPoint) -> Int {
 | |
|         let textStorage = NSTextStorage(attributedString: attributedText!)
 | |
|         let layoutManager = NSLayoutManager()
 | |
|         textStorage.addLayoutManager(layoutManager)
 | |
|         let textContainer = NSTextContainer(size: bounds.size)
 | |
|         textContainer.lineFragmentPadding = 0
 | |
|         textContainer.maximumNumberOfLines = numberOfLines
 | |
|         textContainer.lineBreakMode = lineBreakMode
 | |
|         layoutManager.addTextContainer(textContainer)
 | |
|         return layoutManager.characterIndex(for: point, in: textContainer, fractionOfDistanceBetweenInsertionPoints: nil)
 | |
|     }
 | |
| }
 |