Files
raspberry/iOS/Wallet/Sources/Common/View/CommonViewContainer.swift
2022-05-27 20:21:01 +03:00

72 lines
2.5 KiB
Swift

//
// CommonViewContainer.swift
// PayCash
//
// 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 { view.layer.cornerRadius = cornerRadius }
}
@IBInspectable var color: UIColor = Asset.snow.color
let imgView = UIImageView()
private let view = UIView()
private let contentView = UIView()
private let shadowView = UIView()
override init(frame: CGRect) {
super.init(frame: frame)
prepare()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
prepare()
}
private func prepare() {
clipsToBounds = false
backgroundColor = .clear
view.frame = bounds
view.backgroundColor = Asset.snow.color
view.layer.cornerRadius = cornerRadius
view.clipsToBounds = true
view.translatesAutoresizingMaskIntoConstraints = true
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
insertSubview(view, at: 0)
imgView.image = Asset.commonShadow.image.resizableImage(withCapInsets: .init(top: 30, left: 30, bottom: 30, right: 30))
imgView.frame = .init(x: -12, y: -12, width: frame.width + 24, height: frame.height + 28)
imgView.translatesAutoresizingMaskIntoConstraints = true
imgView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
insertSubview(imgView, at: 0)
// shadowView.backgroundColor = .clear
// shadowView.frame = bounds
// shadowView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
// shadowView.translatesAutoresizingMaskIntoConstraints = true
// shadowView.layer.sublayers?.removeAll()
//// shadowView.addShadow(color: Asset.deepWater.color.withAlphaComponent(0.08), radius: 2, cornerRadius: cornerRadius)
// shadowView.addShadow(color: Asset.deepWater.color.withAlphaComponent(0.08), radius: 24, offset: .init(width: 0, height: 2), cornerRadius: cornerRadius)
// shadowView.clipsToBounds = false
// insertSubview(shadowView, at: 0)
// contentView.backgroundColor = color
// contentView.layer.cornerRadius = cornerRadius
// contentView.clipsToBounds = true
// contentView.frame = bounds
// contentView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
// contentView.translatesAutoresizingMaskIntoConstraints = true
// insertSubview(contentView, at: 1)
}
}