首页 > 学院 > 开发设计 > 正文

获取cell中的button在整个屏幕上的位置

2019-11-14 18:21:11
字体:
来源:转载
供稿:网友

编写cell中得button点击事件

- (IBAction)showButtonClick:(id)sender

{

    UIButton *button = (UIButton *)sender;

    

    UIWindow* window = [UIapplication sharedApplication].keyWindow;

    CGRect rect1 = [button convertRect:button.frame fromView:self.contentView];     //获取button在contentView的位置

    CGRect rect2 = [button convertRect:rect1 toView:window];         //获取button在window的位置

    CGRect rect3 = CGRectInset(rect2, -0.5 * 8, -0.5 * 8);          //扩大热区

 

    //rect3就是最终结果。

}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表