Lio*_*kel 0 uiview cgpoint ios
我很高兴看到这个:如何转换子视图的点的答案 ,它在模拟器上对我来说非常适合.
但由于某种原因,它无法在设备上运行......可能是视图位置由设备管理不同 - 或者它只是另一个谜?或者(希望)我写错了,你们可以帮忙...... :)
这是我的路线:
CGPoint yoel = [imagePressed.imageView convertPoint:imagePressed.frame.origin toView:nil];
Run Code Online (Sandbox Code Playgroud)
我有一个与这个问题有关的不同问题,并注意到我在转换矩形时必须考虑屏幕的比例.(即它在模拟器上工作不是因为它是模拟器,而是因为模拟器处于非视网膜模式)
// the following convertRect is like asking a view: "what would one of your subviews (aView) have for a frame in my (toView) coordinate space if it were to become my subview?
_originalFrame = [[aView superview] convertRect: aView.frame toView: self];
CGFloat scale = [[UIScreen mainScreen] scale];
_originalFrame.origin.x /= scale;
_originalFrame.origin.y /= scale;
_originalFrame.size.width /= scale;
_originalFrame.size.height /= scale;
NSLog(@"Converted Frame: %@", NSStringFromCGRect(_originalFrame));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3531 次 |
| 最近记录: |