0

I have view1 which is an UIImageView and I also have view2 which is a subview of view1 and is a UIImageView too.

I want to move view2 around and I would like it to have alpha=0 where view1 (his superview) has alpha!=1, is that possible? how can I do that?

4

1 回答 1

0

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

使用 UItouch 代理来做这件事.. touchesBegan, touchesMoved,touchesEnded,touchesCancelled 等等..

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

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

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

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

对于拖放,请参阅以下链接

拖动uiview-uiviews之间

如何拖放图像

MoveMe:苹果开发者

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

于 2012-06-19T18:48:36.343 回答