SHARE
TWEET

Untitled

a guest Apr 18th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extension UIView {
  2.   @IBInspectable
  3.   var cornerRadius: CGFloat {
  4.     get {
  5.       return layer.cornerRadius
  6.     }
  7.     set {
  8.       layer.cornerRadius = newValue
  9.     }
  10.   }
  11.  
  12.   @IBInspectable
  13.   var borderColor: UIColor? {
  14.     get {
  15.       if let color = layer.borderColor {
  16.         return UIColor(cgColor: color)
  17.       }
  18.       return nil
  19.     }
  20.     set {
  21.       if let color = newValue {
  22.         layer.borderColor = color.cgColor
  23.       } else {
  24.         layer.borderColor = nil
  25.       }
  26.     }
  27.   }
  28.   @IBInspectable
  29.   var borderWidth: CGFloat {
  30.     get {
  31.       return layer.borderWidth
  32.     }
  33.     set {
  34.       layer.borderWidth = newValue
  35.     }
  36.   }
  37.  
  38.   @IBInspectable
  39.   var shadowRadius: CGFloat {
  40.     get {
  41.       return layer.shadowRadius
  42.     }
  43.     set {
  44.       layer.shadowRadius = newValue
  45.     }
  46.   }
  47.  
  48.   @IBInspectable
  49.   var shadowOpacity: Float {
  50.     get {
  51.       return layer.shadowOpacity
  52.     }
  53.     set {
  54.       layer.shadowOpacity = newValue
  55.     }
  56.   }
  57.  
  58.   @IBInspectable
  59.   var shadowOffset: CGSize {
  60.     get {
  61.       return layer.shadowOffset
  62.     }
  63.     set {
  64.       layer.shadowOffset = newValue
  65.     }
  66.   }
  67.  
  68.   @IBInspectable
  69.   var shadowColor: UIColor? {
  70.     get {
  71.       if let color = layer.shadowColor {
  72.         return UIColor(cgColor: color)
  73.       }
  74.       return nil
  75.     }
  76.     set {
  77.       if let color = newValue {
  78.         layer.shadowColor = color.cgColor
  79.       } else {
  80.         layer.shadowColor = nil
  81.       }
  82.     }
  83.   }
  84. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top