将视图背景设置为能够捏缩放的图像

时间:2021-06-11 22:43:09

I have created a game where a map is on the screen. With this map I would like to have buttons to change scenes and preform actions. The map I have on the screen I would like to be the full screen with pinch zoom capability, along with capability of a button or label to be on top of the image, without the button being zoomed in on or below the scroll view. I tried using a UIScroll View but the button kept zooming in and going below the image. How can I set the background of my View to a pinch zoomable image with labels and buttons on top not being effected in swift and xcode 7?

我创建了一个地图在屏幕上的游戏。有了这张地图,我想有按钮来改变场景和预成型动作。我在屏幕上的地图我想成为具有捏缩放功能的全屏幕,以及按钮或标签位于图像顶部的功能,而不会在滚动视图的上方或下方放大按钮。我尝试使用UIScroll View但按钮保持放大并在图像下方。如何将我的视图背景设置为可缩放的可缩放图像,顶部的标签和按钮不受swift和xcode 7影响?

1 个解决方案

#1


0  

I am not sure if this is the most efficient way, but by calling the method touchesDidBegin() you can move the objects like the TextField and the buttons to a new view that is above the scrollview. Then when touchesDidEnd() you can move them back into the scrollview.

我不确定这是否是最有效的方法,但通过调用方法touchesDidBegin(),您可以将TextField和按钮等对象移动到scrollview上方的新视图。然后当touchesDidEnd()时,您可以将它们移回到scrollview中。

#1


0  

I am not sure if this is the most efficient way, but by calling the method touchesDidBegin() you can move the objects like the TextField and the buttons to a new view that is above the scrollview. Then when touchesDidEnd() you can move them back into the scrollview.

我不确定这是否是最有效的方法,但通过调用方法touchesDidBegin(),您可以将TextField和按钮等对象移动到scrollview上方的新视图。然后当touchesDidEnd()时,您可以将它们移回到scrollview中。