![](/img/trans.png)
[英]How to make UIButton always on top, and change able to change the subviews?
[英]How to force a UIButton to always be on top
我有一個UIButton
和一個UIView
動畫,按下UIButton
時向下滑動。 問題是UIView
掩蓋了UIButton
。 我希望UIButton
始終保持領先UIButton
。
我在viewDidLoad
試過這個:
[self.view bringSubviewToFront:categoryBtn];
雖然不起作用。
謝謝你的幫助
在此主視圖上添加任何UIView
或任何其他視圖后,只需添加此行以作為按鈕的超級視圖
[self.view bringSubviewToFront:categoryBtn];
有關按鈕操作事件的示例,您可以添加任何視圖,然后使用類似下面的代碼。
-(IBAction)yourButton_Clicked:(id)sender
{
///Add some code or view here and then after write this line here see bellow line
[self.view bringSubviewToFront:categoryBtn];
}
另一個答案是可行的,但這正是添加“insertSubview:belowSubview”的事情。
[self.view insertSubview:myNewView belowSubview:_categoryBtn];
這允許您在視圖堆棧上的按鈕下添加新視圖,而不是將其添加到按鈕上方,然后重新排列視圖。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.