如何强制UIButton始终位于顶部

han*_*Dev 3 iphone objective-c uibutton uiview ios

我有一个UIButton和一个UIView动画,按下时向下滑动UIButton.问题是UIView模糊了UIButton.我希望UIButton始终保持领先地位.

我试过这个viewDidLoad:

    [self.view bringSubviewToFront:categoryBtn];
Run Code Online (Sandbox Code Playgroud)

虽然不起作用.

谢谢你的帮助

Par*_*shi 6

在UIView此主视图上添加任何或任何其他视图后,只需添加此行作为按钮的超级视图

[self.view bringSubviewToFront:categoryBtn];
Run Code Online (Sandbox Code Playgroud)

有关按钮操作事件的示例,您可以添加任何视图,然后使用类似下面的代码.

-(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];
}
Run Code Online (Sandbox Code Playgroud)