在Storyboard中使用Xcode 6 UIVisualEffectView [英] Xcode 6 UIVisualEffectView in Storyboard

查看:254
本文介绍了在Storyboard中使用Xcode 6 UIVisualEffectView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找Xcode 6中的对象库,以便UIVisualEffectView在Storyboard中添加模糊。我知道如何以编程方式执行此操作,但我无法在故事板中找到一种方法。

I am looking around the Object Library in Xcode 6 for UIVisualEffectView to add a blur in Storyboard. I know how to do this programmatically, but I can't find a way to do this in the Storyboard.

这在当前测试版中是否不可用,或者是否存在这样做的方法并不那么简单?

Is this unavailable in the current beta, or is there a way to do this that is not so straightforward?

推荐答案

iOS 8.0 Gold Master UPDATE

从iOS 8.0 Gold Master开始,Xcode现在在对象库中提供了一个UIVisualEffectView。要将UIVisualEffectView添加到Storyboard,只需将其从对象库中拖动,放置它,然后使用属性检查器对其进行自定义。

As of the iOS 8.0 Gold Master, Xcode now has a UIVisualEffectView available in the Objects Library. To add a UIVisualEffectView to your Storyboard, just drag it from the Objects Library, position it, and then customize it using the attributes inspector.

iOS 8.0 Beta 5及更早版本

添加 UIVisualEffectView 故事板按照以下步骤操作:

To add a UIVisualEffectView in a Storyboard follow these steps:


  1. 创建一个常规的空UIView(来自对象库)

  2. 将UIView的自定义类设置为 UIVisualEffectView

  3. 将此新视图连接到您的代码,确保您不在故事板中直接向其添加任何子视图(如Apple的文档中所述)。

  4. 继续进行程序化设置(即使用 contentView )。

  1. Create a regular, empty UIView (from the objects library)
  2. Set the custom class of the UIView to UIVisualEffectView:
  3. Connect this new view to your code, make sure that you do not add any subviews directly to it in the Storyboard (as noted in Apple's documentation).
  4. Proceed with the programmatic setup (i.e. with the contentView).

不幸的是,看起来 contentView 属性不是IBOutlet,因此无法在int中设置erface(至少在这个测试版中)。希望他们会在下一个测试版中改变它。我向Apple提交了一个错误报告,可以在故事板中完全创建UIVisualEffectView( Open Radar 对于rdar:// 17742263)。

Unfortunately, it looks like the contentView property is not an IBOutlet and therefore cannot be set in the interface (at least in this beta). Hopefully they will change that in the next beta. I filed a bug report with Apple to be able to create a UIVisualEffectView completely in Storyboards (Open Radar for rdar://17742263).

iOS 8.0 Beta 5及早期 - 编辑

虽然您可以使用上述方法向Storyboard添加 UIVisualEffectView ,但无法从Storyboard初始化该视图。在当前的测试版(iOS 8,Beta 3)中,应该以编程方式创建这些视图以用于任何效果。

While you are able to add a UIVisualEffectView to a Storyboard using the method described above, it is not possible to initialize that view from the Storyboard. In the current beta (iOS 8, Beta 3) these views should be created programmatically for any effect at all.

UIVisualEffects GitHub Repo 演示了一种以各种方式设置和使用新API的简单方法(repo仅在Swift中,没有Objective-C代码)。

The UIVisualEffects GitHub Repo demonstrates an easy way to setup and use the new API in a variety of ways (repo is only in Swift though, no Objective-C code).

这篇关于在Storyboard中使用Xcode 6 UIVisualEffectView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆