Xcode 6 UIVisualEffectView in Storyboard

北慕城南 提交于 2019-12-07 00:33:22

问题


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?


回答1:


iOS 8.0 Gold Master UPDATE

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 and Earlier

To add a UIVisualEffectView in a Storyboard follow these steps:

  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).

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 and Earlier - EDIT

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.

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).



来源:https://stackoverflow.com/questions/24851994/xcode-6-uivisualeffectview-in-storyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!