Peter Warbo
Peter Warbo

Reputation: 11718

Objective-C – Finding out textLabel's position inside an UITableViewCell

I would like to find out the default x position of the textLabel property of an UITableViewCell. What would be the easiest way to accomplish this?

Cheers,

Peter

Upvotes: 0

Views: 407

Answers (2)

Moshe
Moshe

Reputation: 58097

You can get the x position of a UILabel by getting its frame.origin.x property. So for a cell's label, you would use cell.textLabel.frame.origin.x.

Note that there's not much you can do with the default textLabel and detailLabel in a UITableViewCell. Your best bet is often to create custom cell and use that.

Upvotes: 1

jrturton
jrturton

Reputation: 119272

cell.textLabel.frame.origin.x

Gives you the position of the textLabel relative to its containing view.

Upvotes: 2

Related Questions