简体   繁体   English

添加带有按钮的UIView并使其透明,并在该UIVIew后面启用触摸视图

[英]Add UIView with Buttons and make it transparent and enable touch view behind that UIVIew

I am adding images dynamically on VIEW and on same View i have 3 buttons. 我在VIEW和同一个View上动态添加图像,我有3个按钮。 but when i add images they are shown above those buttons i can send them back but i have multiple images on which i have applied gesture so when i click one image it comes to front so i can interact with it (move, rotate). 但是,当我添加图像时,这些图像显示在这些按钮的上方,我可以将其发送回去,但是我在其上应用了手势的图像有多个,因此,当我单击一个图像时,它会出现在前面,以便我可以与之交互(移动,旋转)。

So what i have done i have mainView on which im adding Images and i have Added childView on which i have added buttons and make it transparent. 所以我做了什么,我已经在mainView上添加了图像,并且在我添加了childView上添加了按钮并使它透明。 i can see that image behind buttons but cant interact with them. 我可以看到按钮后面的图像,但无法与它们交互。

I have use this line to make it transparent i think it not good way to make tranparent 我用这条线使其透明,我认为这不是透明的好方法

ButtonsView.backgroundColor = [UIColor clearColor];

Hope you all know what i want to do. 希望大家都知道我想做什么。

在此处输入图片说明

hey mate instead of add child view just add this button on your this same view and give backgroundColor clear and then in this bellow method try this.. 嘿伙伴,而不是添加子视图,只需在同一视图上添加此按钮,并清除backgroundColor,然后在此波纹管方法中尝试此操作即可。

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    [touch locationInView:yourView];
else if([touch.view isKindOfClass:[UIImageView class]])
    {
        UIImageView *tempImage=(UIImageView *) touch.view;
        [yourView bringSubviewToFront:tempImage];
        [yourView bringSubviewToFront:yourButtons];/// set superview as a buttons..
    }
}

i hope this help you.. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM