SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
iOS/UILabel+TapLocation.m
1 #import "UILabel+TapLocation.h"
2
3 @implementation UILabel (TapLocation)
4
5 - (unsigned)characterAtTap:(UITapGestureRecognizer *)tap
6 {
7 CGPoint tapLocation = [tap locationInView:self];
8
9 NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:self.attributedText];
10 NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
11 [textStorage addLayoutManager:layoutManager];
12
13 NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:CGSizeMake(self.frame.size.width,
14 self.frame.size.height + 256)];
15 textContainer.lineFragmentPadding = 0;
16 textContainer.maximumNumberOfLines = 256;
17 textContainer.lineBreakMode = self.lineBreakMode;
18
19 [layoutManager addTextContainer:textContainer];
20
21 return [layoutManager characterIndexForPoint:tapLocation
22 inTextContainer:textContainer
23 fractionOfDistanceBetweenInsertionPoints:NULL];
24
25 }
26
27 @end
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.