UIImageView 像素完美的“触摸开始”,用于 UIImage 的非透明部分
开发iPhone应用程序,我使用了UIImageview,并且设置了不规则形状的图像
// uiimageview type shutter
shutter = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,32.5)];
//setting image on shutter
UIImage* shutterimg = [UIImage imageNamed:@"trayshutter.png"];
[shutter setImage:shutterimg];
// User interaction
shutter.userInteractionEnabled=YES;
,并且使用touchesbegan进行触摸,
一切都很好,但问题是我还在CGRectMake占用的所有矩形区域中获取事件(即0,0,320, 32.5)的 imageview,而我只需要图像上的事件(其形状为 -----|||||-----)。
如何确保我仅在图像上获取事件,而不是在 cgrectmake 覆盖的其余区域上获取事件?
developing iphone app, I have used a UIImageview and i have set an image of irregular shape
// uiimageview type shutter
shutter = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,32.5)];
//setting image on shutter
UIImage* shutterimg = [UIImage imageNamed:@"trayshutter.png"];
[shutter setImage:shutterimg];
// User interaction
shutter.userInteractionEnabled=YES;
and i get touches using touchesbegan
everything is fine, but issue is I also get events in all the rectangle area occupied by the CGRectMake (i.e. 0,0,320,32.5) of imageview, whereas i require events only on the image (which is of shape of -----|||||-----).
How can i make sure that i get events only on the image and not on the rest of area covered by cgrectmake ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑:也许你可以尝试
UITapGestureRecognizer
代替:EDIT: maybe you can try
UITapGestureRecognizer
instead: