remove actions from mflabel
This commit is contained in:
parent
1f83778680
commit
7d7284bd8d
@ -20,8 +20,6 @@
|
||||
// Set this to use a custom sizing object during updateView instead of the standard.
|
||||
@property (nonatomic, strong, nullable) MFSizeObject *sizeObject;
|
||||
|
||||
@property (nonatomic, strong, nullable) NSDictionary *actions;
|
||||
|
||||
// Set the font and set to scale
|
||||
- (void)setFont:(nonnull UIFont *)font scale:(BOOL)scale;
|
||||
|
||||
|
||||
@ -199,7 +199,6 @@
|
||||
NSArray *attributes = [json array:@"attributes"];
|
||||
if (attributes) {
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:label.text attributes:@{NSFontAttributeName:label.font,NSForegroundColorAttributeName:label.textColor}];
|
||||
NSMutableDictionary *actions = [NSMutableDictionary new];
|
||||
for (NSDictionary *attribute in attributes) {
|
||||
NSNumber *location = [attribute optionalNumberForKey:@"location"];
|
||||
NSNumber *length = [attribute optionalNumberForKey:@"length"];
|
||||
@ -229,14 +228,12 @@
|
||||
}
|
||||
} else if ([type isEqualToString:@"link"]) {
|
||||
label.userInteractionEnabled = YES;
|
||||
[actions setObject:attribute forKey:[NSValue valueWithRange:range]];
|
||||
}
|
||||
}
|
||||
}
|
||||
label.attributedText = attributedString;
|
||||
if ([label isKindOfClass:[MFLabel class]]) {
|
||||
MFLabel *mflabel = (MFLabel *)label;
|
||||
mflabel.actions = actions;
|
||||
}
|
||||
|
||||
}
|
||||
@ -299,25 +296,4 @@
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - action
|
||||
|
||||
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
NSDictionary *actionMap = [self areTouchesInActionString:touches];
|
||||
if (actionMap) {
|
||||
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:actionMap additionalData:nil delegate:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDictionary *)areTouchesInActionString:(NSSet<UITouch *> *)touches {
|
||||
CGPoint location = [[touches anyObject] locationInView:self];
|
||||
for (NSValue *valueOfRange in self.actions.allKeys) {
|
||||
NSRange range = [valueOfRange rangeValue];
|
||||
CGRect rect = [self boundingRectForCharacterRange:range];
|
||||
if (CGRectContainsPoint(rect, location)){
|
||||
return [self.actions objectForKey:valueOfRange];
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user