繁体   English   中英

“pointInside:”如何运作?

[英]how does “pointInside:” work?

我正在进行一些热门测试并遇到了令人困惑的情况。

我有两个按钮“favoriteButton”和“shareButton”。 即使按钮不重叠,以下代码也会导致'a'和'b'为真:

CGPoint dunno = CGPointMake(11, 7);

BOOL a = [self.favoriteButton pointInside:dunno withEvent:nil];
BOOL b = [self.shareButton pointInside:dunno withEvent:nil];

并且只是为了证明它,这里是调用此代码时两个按钮的描述输出。

Printing description of _favoriteButton:
<UIButton: 0x5da8c90; frame = (10 6; 37 35); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x5da8d40>>
Printing description of _shareButton:
<UIButton: 0x5da7150; frame = (46 6; 30 35); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x5da59b0>>

这里发生了什么? 我误解了输出应该是什么?

那么@Nippysaurus根据文档

http://developer.apple.com/library/iOS/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instm/UIView/pointInside:withEvent

A point that is in the receiver’s local coordinate system (bounds).

这意味着点CGPoint dunno = CGPointMake(11, 7); 在视图内部,因为视图的边界将与同一视图的框架不同。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM