ios - 为整个 UISplitViewController 添加背景

标签 ios image view background uisplitviewcontroller

嘿,我想在我的 UISplitViewController 中添加一张背景图片,它横跨整个 iPad 屏幕,并且在我的主视图和详细 View 下方都可见。

我已经尝试了多种不同的方法,但尚未成功。如果我将它放在 splitView.view 中,它只是覆盖在两个 subview Controller 中的所有内容之上。如果我将它放在主视图 Controller 中,我可以在那里正常执行操作(在它上面放置一个 UITableView 等),但它会覆盖详细 View Controller 中的所有内容。我尝试的另一种方法是将我的背景图像放在它自己的 View Controller 中,将整个 Split View Controller 放在该 View Controller 中,但无论我设置 Split View Controller 的 alpha 什么,背景仍然是黑色的。

如果有人能指出我如何让​​这项工作成功,那就太棒了,谢谢!

最佳答案

成功了!

首先按照 Apple 在此处以编程方式设置 UISplitViewController 的示例进行操作:http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/iPadControllers/iPadControllers.html

然后在将 VC 添加到窗口之前添加这一行:

splitVC.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.jpg"]];

关于ios - 为整个 UISplitViewController 添加背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7094738/

相关文章:

ios - 尝试在 View 不在窗口层次结构中的 UIViewController 上呈现 UIViewController

ios - 使用 NSPredicate 在自定义对象的 NSArray 中搜索字符串

javascript - 如何检测图片路径是否有效?

image - 在博客上添加 svg 图片作为标题

asp.net - 在 ASP.NET MVC 中显示另一个 Controller 的 View

android - 在 Android 上一次触摸两个 View

ios - React Native中的应用导航:超出最大调用堆栈大小

ios - iOS8 本地通知可以触发代码吗?

ios - SwiftUI 可观察对象不更新 UI

javascript - 如何将 HTML 文件转换为 GIF