如何在iPhone中设置此布局需要一些帮助 [英] How to set this Layout in iPhone need Some help

查看:108
本文介绍了如何在iPhone中设置此布局需要一些帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现了一些像应用程序一样的绘画。为此,布局如下所示:

I have Implement Some paint like application. For that the Layout is like as below:

这里有One View和两个按钮。在我的应用程序中,我从Button2中选择颜色,然后在View上绘图。
但问题是,当我选择颜色时,如果我在视图上执行绘制,所有工作文件但是如果那个颜色来自Button1,它也会在该按钮上绘制1。我想设置就像选择颜色不应该在Button1上绘画,只在视图上绘画。
那么我应该怎么做?
我想在View前面设置Button1并且不允许在它上面绘画。
请指导我正确的关于这个母亲。
谢谢。

Here, there is One View and two buttons. In My application i am selecting the colour from Button2 and then doing drawing on View. But the Problem is while i am selecting the Colour and if i do the Paint on the View, all works file but if that paint come over the Button1, it also paint on that button1. I want set as like that the selection colour Should not be paint on the Button1 and only paint on the View. So for that What Should i have to do ? I want to set the Button1 in front of the View and do not allow to paint on it. please Guide me proper regarding this mater. Thanks.

推荐答案

您必须确保您的按钮不是您正在绘制的视图的子视图。

You have to make sure your buttons are not subviews of the view you are drawing in.

最简单的方法是在界面构建器中组织按钮和视图,以便在窗口中显示UIView以及必须在比你的UIView更高的层,但不能在你的UIView里面。如果网站允许我发布图片我会发布。然后,您需要创建一个UIView IBOutlet来连接到Interface Builder中的UIView并在您的代码中绘制。

The simplest way to do this is to organize your buttons and your view in interface builder so that you have a UIView within your window as well as your buttons which must be on a higher layer than your UIView but cannot be inside your UIView. I would post pictures if the site would let me. You will then need to make a UIView IBOutlet to attatch to the UIView in Interface Builder and to draw to in your code.

要以编程方式执行此操作,请在创建按钮,创建一个UIView并通过使用(如果myView是你的UIView)将它作为子视图添加到你的viewController的视图

To do this programmatically, after you have created your buttons, create a UIView and add it as a subview to your viewController's view by using (if myView is your UIView)

[self.view addSubview:myView] 

然后使用

[self.view send SubviewToBack:myView]

确保它在你的其他子视图(你的按钮)后面。绘制到myView,它应该出现在按钮后面。

to make sure it is behind your other subviews (your buttons). Draw to myView and it should appear behind the buttons.

这篇关于如何在iPhone中设置此布局需要一些帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆