// // CommonViewContainer.swift // Wallet // // Created by Igor on 19.02.2021. // Copyright © 2021 AM. All rights reserved. // import UIKit @IBDesignable class CommonViewContainer: UIView { @IBInspectable var cornerRadius: CGFloat = 16 { didSet { self.contentView.layer.cornerRadius = self.cornerRadius } } @IBInspectable var color: UIColor = Asset.snow.color let imgView = UIImageView() let contentView = UIView() override init(frame: CGRect) { super.init(frame: frame) self.prepare() } required init?(coder: NSCoder) { super.init(coder: coder) self.prepare() } private func prepare() { self.clipsToBounds = false self.backgroundColor = .clear self.contentView.frame = bounds self.contentView.backgroundColor = Asset.snow.color self.contentView.layer.cornerRadius = self.cornerRadius self.contentView.clipsToBounds = true self.contentView.translatesAutoresizingMaskIntoConstraints = true self.contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight] self.insertSubview(self.contentView, at: 0) self.imgView.image = Asset.commonShadow.image.resizableImage(withCapInsets: .init(top: 30, left: 30, bottom: 30, right: 30)) self.imgView.frame = .init(x: -12, y: -12, width: frame.width + 24, height: frame.height + 28) self.imgView.translatesAutoresizingMaskIntoConstraints = true self.imgView.autoresizingMask = [.flexibleWidth, .flexibleHeight] self.insertSubview(self.imgView, at: 0) } }