2012-11-23 34 views
0

我在VIEW上添加圖像動態,並在同一視圖我有3個按鈕。但是當我添加圖像時,他們顯示在這些按鈕上方,我可以將它們發回,但我有多個圖像,因此當我點擊一個圖像時,它會出現在前面,所以我可以與它進行交互(移動,旋轉)。添加UIView的按鈕,並使其透明,並啓用後面的觸摸視圖UIVIew

所以我做了什麼,我有我的主視圖添加圖像,我已添加childView我已添加按鈕,並使其透明。我可以看到按鈕後面的圖像,但不能與它們交互。

我必須使用此行,使之透明,我認爲這不是好辦法,使tranparent

ButtonsView.backgroundColor = [UIColor clearColor]; 

希望大家知道我想做的事情。

enter image description here

回答

0

嘿交配,而不是添加子視圖中只需添加上你的這個相同的觀點這個按鈕,並給予明確的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.. 
    } 
} 

我希望這會幫助你..

+0

謝謝。讓我試試這個 – Zohaib

+1

謝謝,我沒有實現touchesBegan。我剛纔在前面展示了我的圖片,然後在前面展示了我的按鈕。如果([b isKindOfClass:[UIButton class]]){[self.view bringSubviewToFront:b];} [self.view bringSubviewToFront:b]; } }將每個按鈕放在前面。謝謝 – Zohaib