[英]How to create a see through button with “blurred” background in iOS 7
I am updating my app to iOS 7 and wanted to improve the UI. 我正在将我的应用更新到iOS 7,并希望改进用户界面。 I want to create a see through background like Control Center.
我想创建一个像Control Center这样的透视背景。 So basically I have a button, which I would like to have a see through and "blurred" background like control center.
所以基本上我有一个按钮,我希望看到通过和“模糊”的背景像控制中心。 Thanks!
谢谢!
There's nothing to stop you using a UIToolbar. 没有什么可以阻止你使用UIToolbar。
Create a UIView as a base view with clear background, add a UIToolbar anchored to it's edges so it fills the view and then add your other controls to your base view above the toolbar. 创建一个UIView作为具有清晰背景的基本视图,添加一个固定在其边缘的UIToolbar,以便填充视图,然后将其他控件添加到工具栏上方的基本视图中。
It'll look for example like this: 它会看起来像这样的例子:
The blurring effect is not available as a public API. 模糊效果不可用作公共API。 There are third party implementations available, such as FXBlurView , which I can recommend.
有第三方实现可用,例如FXBlurView ,我可以推荐。
You shouldn't really be using a toolbar. 你不应该真的使用工具栏。 It's called toolbar for a reason.
它被称为工具栏是有原因的。 One way to go would be to take a snapshot image of your background and blur it (you can use UIImage+ImageEffects category included in Apple samples to achieve consistent effect).
一种方法是拍摄背景的快照图像并将其模糊(您可以使用Apple样本中包含的UIImage + ImageEffects类别来实现一致的效果)。 You can then just crop the image to desired frame and use it as a background of your button.
然后,您可以将图像裁剪为所需的帧并将其用作按钮的背景。
Are you looking to have a 'dynamic' blur effect (like in Control Center)? 您是否希望获得“动态”模糊效果(如在控制中心中)? It's still doable, but it makes things more complicated.
它仍然可行,但它使事情变得更复杂。
You can also create blur effects with GUPImage Framework here is a full tutorial about it iOS blur effect tutorial . 您还可以使用GUPImage Framework创建模糊效果这里是一个关于iOS模糊效果教程的完整教程 。 The tutorial also explains why you shouldn't use toolbar for blur effect creation
本教程还解释了为什么不应使用工具栏来创建模糊效果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.