iOS cell的坐标转为window的坐标、弹框位置在cell下面

 iOS cell的坐标转为window的坐标。

  CGFloat alertViewWith = 200;//宽自己定义
      
//(只有这两句是核心代码)拿到当前cell的frame,转换为window的坐标.
      CGRect rectInTableView = [tableView rectForRowAtIndexPath:indexPath];
      CGRect rect = [tableView convertRect:rectInTableView toView:[UIApplication sharedApplication].keyWindow];


//这里是 y + 高
      CGFloat alertViewHight = rect.origin.y + rect.size.height;
      NSLog(@"%@",NSStringFromCGRect(rect));
//最后设置你的弹框frame
      alertView.frame = CGRectMake(weakCell.subTitleTextField.x,alertViewHight, alertViewWith, 200);

效果图

猜你喜欢

转载自blog.csdn.net/ximiaoweilai/article/details/105641658