获取屏幕上的某个控件相对位置,尤其是tableviewcell上的某一个控件的相对位置

我的需求就是tableviewcell上的按钮,点击就会出现一个弹框:

主要就是获取,所点击的cell上控件的相对位置;

CGPoint buttonCenter = CGPointMake(btn.bounds.origin.x + btn.bounds.size.width/2,
                                           btn.bounds.origin.y + btn.bounds.size.height/2);
CGPoint btnorigin = [btn convertPoint:buttonCenter toView:self.view]; NSLog(@"sender =x: %f y :%f",btnorigin.x,btnorigin.y );

这样就能获取了

原文地址:https://www.cnblogs.com/liuwenqiang/p/6660070.html