简体   繁体   English

iOS开发:保证顶层

[英]iOS development: guaranteed top layer

Is it possible to programmatically (not via xib) add a button or other control on an arbitrary iOS app which is always on top? 是否可以通过编程方式(而不是通过xib)在始终位于顶部的任意iOS应用上添加按钮或其他控件? I want to make a bit more advanced screenshot app where the developer has to put (preferably) one line of code in his app which will show a button in the left top (for instance) and when the user clicks that it screenshots and opens a layer which, again, is guaranteed on top to enter some information and share via Twitter. 我想制作一个更高级的屏幕截图应用程序,其中开发人员必须在其应用程序中放置(最好是)一行代码(例如),该代码行将在左上角显示一个按钮(例如),并且当用户单击该按钮时,它会截图并打开一个再次保证在顶层可以输入一些信息并通过Twitter分享。

Can that be done and how? 能做到吗?如何做到?

You could either just make sure to call: 您可以确保致电:

[self.view bringSubviewToFront:topView];

Or possibly add it to you app delegate window: 或者可以将其添加到您的应用程序委托窗口中:

AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[[delegate window] topView];

Note: this will be on top of all views in every view controller until you remove it. 注意:这将在每个视图控制器所有视图的顶部,直到您将其删除。

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

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