J'utilise NSAttributed String, qui contient plusieurs couleurs.Veuillez vérifier cette image. Obtenir la couleur de chaîne NSAttributed sur le robinet (détection de couleur de mot)
Je sélection d'un mot à l'aide TapGesture ... Pour i Exemple- ont choisi « rouge »
- (void)tapGestureRecognizerHandle:(UITapGestureRecognizer *)tapGestureRecognizer {
SETextView *textView = self.textV;
CGPoint location = [tapGestureRecognizer locationInView: self.textV];
NSLog(@"Tap Gesture Coordinates: %.2f %.2f -- %@", location.x, location.y,textView.text);
CGPoint position = CGPointMake(location.x, location.y);
//get location in text from textposition at point
UITextPosition *tapPosition = [textView closestPositionToPoint:position];
UITextRange *textRange = [textView.tokenizer rangeEnclosingPosition:tapPosition withGranularity:UITextGranularityWord inDirection:UITextLayoutDirectionRight];
NSString *tappedSentence;
if (textRange != nil)
{
tappedSentence = [textView textInRange:textRange];
}
else
{
tappedSentence = textView.text;
}
}
Maintenant, je veux connaître la couleur du mot sélectionné tout d'une moindre idée s'il vous plaît partager
Merci
Vous êtes utiliser ce label: https://github.com/TTTAttributedLabel/TTTAttributedLabel –
pas Kirit ... J'utilise textview simple avec Tapgesture –
@VarinderSingh SETextView est votre propre classe ou est-ce de la bibliothèque? –