iOS:触摸Imageview时发生的事件

编程入门 行业动态 更新时间:2024-10-27 19:30:27
本文介绍了iOS:触摸Imageview时发生的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个带png的ImageView,我想这样做:当有人触摸此imageview时,其alpha更改为0.0,这可能吗?(全部不带按钮)

I have an ImageView with a png and I want to do this: when someone touch this imageview it's alpha change to 0.0, is it possible? (all without buttons)

推荐答案

是的,有可能.例如,您可以按照以下步骤进行操作:

Yes, it is possible. For example you can do that with following steps:

  • 将图像视图的userInteractionEnabled属性设置为YES-这样它将接收触摸事件
  • 向其中添加UITapGestureRecongnizer
  • 在手势处理程序中将视图的Alpha设置为0.0,您也可以使用动画来做到这一点:

  • set image view's userInteractionEnabled property to YES - so it will receive touch events
  • add UITapGestureRecongnizer to it
  • in gesture handler set view's alpha to 0.0, you can do that with animation as well: [UIView animateWithDuration:0.5 animations:^(void){ imageView.alpha = 0.0f; }];

  • 更多推荐

    iOS:触摸Imageview时发生的事件

    本文发布于:2023-11-06 16:15:38,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1564182.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:发生   事件   iOS   Imageview

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!