|
class ButtonPanelView: UIView { |
|
|
|
// ... |
|
|
|
override init(frame: CGRect) { |
|
super.init(frame: frame) |
|
backgroundColor = UIColor(red: 81/255, green: 166/255, blue: 219/255, alpha: 1) |
|
|
|
layer.cornerRadius = buttonSize / 2 |
|
layer.shadowColor = UIColor.lightGray.cgColor |
|
layer.shadowOpacity = shadowOpacity |
|
|
|
layer.shadowOffset = .zero |
|
|
|
addSubview(containerStackView) |
|
setConstraints() |
|
} |
|
|
|
required init?(coder: NSCoder) { |
|
fatalError("init(coder:) has not been implemented") |
|
} |
|
|
|
private func setConstraints() { |
|
// Main button |
|
menuButton.translatesAutoresizingMaskIntoConstraints = false |
|
menuButton.widthAnchor.constraint(equalToConstant: buttonSize).isActive = true |
|
menuButton.heightAnchor.constraint(equalToConstant: buttonSize).isActive = true |
|
|
|
// Dog button |
|
dogButton.translatesAutoresizingMaskIntoConstraints = false |
|
dogButton.widthAnchor.constraint(equalToConstant: buttonSize).isActive = true |
|
dogButton.heightAnchor.constraint(equalToConstant: buttonSize).isActive = true |
|
|
|
// Cat button |
|
catButton.translatesAutoresizingMaskIntoConstraints = false |
|
catButton.widthAnchor.constraint(equalToConstant: buttonSize).isActive = true |
|
catButton.heightAnchor.constraint(equalToConstant: buttonSize).isActive = true |
|
|
|
// Container stack view |
|
containerStackView.translatesAutoresizingMaskIntoConstraints = false |
|
containerStackView.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true |
|
containerStackView.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true |
|
|
|
translatesAutoresizingMaskIntoConstraints = false |
|
self.widthAnchor.constraint(equalTo: containerStackView.widthAnchor).isActive = true |
|
self.heightAnchor.constraint(equalTo: containerStackView.heightAnchor).isActive = true |
|
} |
|
|
|
// ... |
|
} |