【发布时间】:2012-05-18 21:34:50
【问题描述】:
我有 view1,它是 UIImageView,我也有 view2,它是 view1 的子视图,也是 UIImageView。
我想移动 view2,我希望它有 alpha=0,其中 view1(他的超级视图)有 alpha!=1,这可能吗?我该怎么做?
【问题讨论】:
标签: uiview uiimageview alpha
我有 view1,它是 UIImageView,我也有 view2,它是 view1 的子视图,也是 UIImageView。
我想移动 view2,我希望它有 alpha=0,其中 view1(他的超级视图)有 alpha!=1,这可能吗?我该怎么做?
【问题讨论】:
标签: uiview uiimageview alpha
可以通过不同的方式移动/拖动 view2。
使用 UItouch 代理来执行此操作.. touchesBegan、touchesMoved、touchesEnded、touchesCancelled 等..
您可以通过 2 种不同的方式进行操作。
1.创建一个继承自 UiView 的子类,命名为 view2 并实现上述触摸委托并创建其 obj 并添加为 view1 的子视图。然后您可以在 view2 中发生触摸时使触摸委托工作。
在 touchesBegan,touchesMoved 代理中,为拖动操作进行编码。
2.在主视图 touchesBegan,touchesMoved delegates 中,检查触摸点是否与 view2 框架相交。 如果是,请执行 view2 拖动的代码
有关拖放,请参阅以下链接
对于 setAlpha,您可以根据自己的条件使用 UIView 方法 yourUiView.setAlpha = 1.0 或 yourUiView.setAlpha = 0.0
【讨论】: