开发者

Detecting the coordinates on an object and outputting them to the NSLog

开发者 https://www.devze.com 2023-03-24 02:17 出处:网络
How exactly would I detect the coordinates of an object, such as a view named \"content\", and output this to the log? Thank开发者_如何学JAVAs for your help!You can also do

How exactly would I detect the coordinates of an object, such as a view named "content", and output this to the log? Thank开发者_如何学JAVAs for your help!


You can also do

NSLog(@"position: %@",NSStringFromCGPoint(object.center))

or.. what sometimes is more interesting the frame coordinates:

NSLog(@"frame: %@",NSStringFromCGRect(object.frame))


You could use:

NSLog(@"Object.x: %f, Object.y: %f", CGRectGetMinX(object.frame), CGRectGetMinY(object.frame));

Alternatively, you can get the center like so:

NSLog(@"Object.x: %f, Object.y: %f", object.center.x, object.center.y);
0

精彩评论

暂无评论...
验证码 换一张
取 消