Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the position(x,y) of a letter in UILabel [duplicate]

I have a label with the text @"Good,Morning"

I want to find the position(x,y) of letter ","(Comma) in the label.

Can anyone tell & Suggest me that how to find this..

like image 925
surendher Avatar asked Dec 18 '13 05:12

surendher


1 Answers

Try this code.

NSRange range = [@"Good,Morning" rangeOfString:@","];
NSString *prefix = [@"Good,Morning" substringToIndex:range.location];
CGSize size = [prefix sizeWithFont:[UIFont systemFontOfSize:18]];
CGPoint p = CGPointMake(size.width, 0);
NSLog(@"p.x: %f",p.x);
NSLog(@"p.y: %f",p.y);

Hope this will help you.

like image 158
sathiamoorthy Avatar answered Oct 11 '22 15:10

sathiamoorthy