cell
在屏幕中的位置
let rect = tableView.convert(tableView.rectForRow(at: indexPath), to: tableView.superview)
cell
中的控件在屏幕中的位置
class MyTableViewCell: UITableViewCell {
//省略代码
......
@objc func imageClick(tap: UITapGestureRecognizer) {
guard let image = tap.view else { return }
//let window = UIApplication.shared.windows.filter{ $0.isKeyWindow }.first
let rect = image.convert(image.convert(image.frame, from: contentView), to: window)
}
@objc func buttonClick(_ button: UIButton) {
//let window = UIApplication.shared.windows.filter{ $0.isKeyWindow }.first
let rect = button.convert(button.convert(button.frame, from: contentView), to: window)
}
}
网友评论