【问题标题】:Setting a view alpha设置视图 alpha
【发布时间】:2012-05-18 21:34:50
【问题描述】:

我有 view1,它是 UIImageView,我也有 view2,它是 view1 的子视图,也是 UIImageView

我想移动 view2,我希望它有 alpha=0,其中 view1(他的超级视图)有 alpha!=1,这可能吗?我该怎么做?

【问题讨论】:

    标签: uiview uiimageview alpha


    【解决方案1】:

    可以通过不同的方式移动/拖动 view2。

    使用 UItouch 代理来执行此操作.. touchesBegan、touchesMoved、touchesEnded、touchesCancelled 等..

    您可以通过 2 种不同的方式进行操作。

    1.创建一个继承自 UiView 的子类,命名为 view2 并实现上述触摸委托并创建其 obj 并添加为 view1 的子视图。然后您可以在 view2 中发生触摸时使触摸委托工作。

    在 touchesBegan,touchesMoved 代理中,为拖动操作进行编码。

    2.在主视图 touchesBegan,touchesMoved delegates 中,检查触摸点是否与 view2 框架相交。 如果是,请执行 view2 拖动的代码

    有关拖放,请参阅以下链接

    drag-uiview-between-uiviews

    how-to-drag-and-drop-images

    MoveMe : Apple developer

    对于 setAlpha,您可以根据自己的条件使用 UIView 方法 yourUiView.setAlpha = 1.0 或 yourUiView.setAlpha = 0.0

    【讨论】:

      猜你喜欢
      • 2011-06-23
      • 1970-01-01
      • 2013-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-24
      • 2015-07-26
      • 1970-01-01
      相关资源
      最近更新 更多