You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.3 KiB

  1. # VisualEffectView
  2. [![Build Status](https://travis-ci.org/efremidze/VisualEffectView.svg?branch=master)](https://travis-ci.org/efremidze/VisualEffectView)
  3. [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
  4. [![Language](https://img.shields.io/badge/Swift-4-orange.svg?style=flat)](https://swift.org)
  5. [![Version](https://img.shields.io/cocoapods/v/VisualEffectView.svg?style=flat)](http://cocoapods.org/pods/VisualEffectView)
  6. [![License](https://img.shields.io/cocoapods/l/VisualEffectView.svg?style=flat)](http://cocoapods.org/pods/VisualEffectView)
  7. **VisualEffectView** is a blur effect library with tint color support. This library uses the [UIVisualEffectView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIVisualEffectView/) to generate the blur.
  8. ![Demo GIF](https://thumbs.gfycat.com/EnormousLightBullmastiff-size_restricted.gif)
  9. [Demo Video](https://gfycat.com/EnormousLightBullmastiff)
  10. ```
  11. $ pod try VisualEffectView
  12. ```
  13. ## Requirements
  14. - iOS 9.0+
  15. - Xcode 9.0+
  16. - Swift 5 (VisualEffectView 4.x), Swift 4 (VisualEffectView 3.x), Swift 3 (VisualEffectView 2.x), Swift 2 (VisualEffectView 1.x)
  17. ## Usage
  18. Add an instance of VisualEffectView to your view.
  19. ```swift
  20. import VisualEffectView
  21. let visualEffectView = VisualEffectView(frame: CGRect(x: 0, y: 0, width: 320, height: 480))
  22. // Configure the view with tint color, blur radius, etc
  23. visualEffectView.colorTint = .redColor()
  24. visualEffectView.colorTintAlpha = 0.2
  25. visualEffectView.blurRadius = 10
  26. visualEffectView.scale = 1
  27. addSubview(visualEffectView)
  28. ```
  29. Depending on the desired effect, the effect may affect content layered behind the view or content added to the visual effect view’s contentView. After you add the visual effect view to the view hierarchy, add any subviews to the contentView property of the visual effect view. Do not add subviews directly to the visual effect view itself. Refer to the [UIVisualEffectView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIVisualEffectView/) for more info.
  30. For more examples, take a look at the example project.
  31. ### Customization
  32. ```swift
  33. var colorTint: UIColor // tint color. default is nil
  34. var colorTintAlpha: CGFloat // tint color alpha. default is 0
  35. var blurRadius: CGFloat // blur radius. default is 0
  36. var scale: CGFloat // scale factor. default is 1
  37. ```
  38. ### Storyboard Support
  39. Works great with storyboards and xibs.
  40. ## Installation
  41. ### CocoaPods
  42. To install with [CocoaPods](http://cocoapods.org/), simply add this in your `Podfile`:
  43. ```ruby
  44. use_frameworks!
  45. pod "VisualEffectView"
  46. ```
  47. ### Carthage
  48. To install with [Carthage](https://github.com/Carthage/Carthage), simply add this in your `Cartfile`:
  49. ```ruby
  50. github "efremidze/VisualEffectView"
  51. ```
  52. ### Manually
  53. 1. Download and drop ```VisualEffectView.swift``` in your project.
  54. 2. Congratulations!
  55. ## Communication
  56. - If you **found a bug**, open an issue.
  57. - If you **have a feature request**, open an issue.
  58. - If you **want to contribute**, submit a pull request.
  59. ## Disclaimer
  60. VisualEffectView utilizes a private UIKit API to do its magic. Use caution, submitting this code to the App Store adds the risk of being rejected!
  61. ## Credits
  62. https://github.com/collinhundley/APCustomBlurView
  63. ## License
  64. VisualEffectView is available under the MIT license. See the LICENSE file for more info.