Advertisement
srk72

TableViewCollectionView Shadow & Corner Radius Togather custom

Jul 6th, 2022 (edited)
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.86 KB | None | 0 0
  1. //
  2. //  TableViewDesign.swift
  3. //  Tutor Demo
  4. //
  5. //  Created by Macmini on 06/12/21.
  6. //
  7.  
  8. import Foundation
  9. import UIKit
  10.  
  11. @IBDesignable class TableViewDesign: UIView
  12. {
  13.     @IBInspectable var cornerRedius: CGFloat = 10
  14.     @IBInspectable var shadowColor : UIColor? = UIColor.black
  15.     @IBInspectable var shadowOffSetWidth : Int = 0
  16.     @IBInspectable var shadowOffSetHeight : Int = 0
  17.     @IBInspectable var shadowOpacity : Float = 0.2
  18.    
  19.     override func layoutSubviews()
  20.     {
  21.         layer.cornerRadius = cornerRedius
  22.         layer.shadowColor = shadowColor?.cgColor
  23.         layer.shadowOffset = CGSize(width: shadowOffSetWidth, height: shadowOffSetHeight)
  24.         let shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: cornerRedius)
  25.         layer.shadowPath = shadowPath.cgPath
  26.         layer.shadowOpacity = shadowOpacity
  27.        
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement