説明なし

UIImageViewExt.swift 680B

1234567891011121314151617181920212223242526
  1. //
  2. // UIImageViewExt.swift
  3. // ExtensionKit
  4. //
  5. // Created by FFIB on 2017/9/14.
  6. // Copyright © 2017年 FFIB. All rights reserved.
  7. //
  8. import UIKit
  9. extension UIImageView {
  10. public func blur(withStyle style: UIBlurEffectStyle) {
  11. let blurEffect = UIBlurEffect(style: style)
  12. let blurEffectView = UIVisualEffectView(effect: blurEffect)
  13. blurEffectView.frame = bounds
  14. blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
  15. addSubview(blurEffectView)
  16. clipsToBounds = true
  17. }
  18. public func blurred(withStyle style: UIBlurEffectStyle) -> UIImageView {
  19. blur(withStyle: style)
  20. return self
  21. }
  22. }