Is that the x position of the start of the word? Just measure the string that precedes the word....
- (CGFloat)getXOriginOfString:(NSString *)string fromString:(NSString *)sentenceString inLabel:(UILabel *)label {
CGFloat maxWidth = CGRectGetMaxX(label.frame);
NSRange range = [sentenceString rangeOfString:string];
NSString *prefix = [sentenceString substringToIndex:range.location];
return [prefix sizeWithFont:label.font
forWidth:maxWidth
lineBreakMode:NSLineBreakByWordWrapping].width;
}
The end of the word will be this result + the stringSize
in the code you posted. Or maybe I'm misunderstanding the question?