Skip to content

Instantly share code, notes, and snippets.

@apatronl
Last active April 8, 2021 15:23
Show Gist options
  • Save apatronl/23a73ff7c0ebe1e858707d0eab71d89a to your computer and use it in GitHub Desktop.
Save apatronl/23a73ff7c0ebe1e858707d0eab71d89a to your computer and use it in GitHub Desktop.
import UIKit
fileprivate let buttonSize: CGFloat = 56
fileprivate let shadowOpacity: Float = 0.7
class ButtonPanelView: UIView {
lazy var menuButton: UIButton = {
let button = UIButton(frame: .zero)
button.setTitle("➕", for: .normal)
button.backgroundColor = .clear
button.layer.cornerRadius = buttonSize / 2
button.addTarget(
self, action: #selector(handleTogglePanelButtonTapped(_:)), for: .touchUpInside)
return button
}()
lazy var dogButton: UIButton = {
let button = UIButton(frame: .zero)
button.setTitle("🐶", for: .normal)
button.layer.cornerRadius = buttonSize / 2
button.isHidden = true
return button
}()
lazy var catButton: UIButton = {
let button = UIButton(frame: .zero)
button.setTitle("🐱", for: .normal)
button.layer.cornerRadius = buttonSize / 2
button.isHidden = true
return button
}()
lazy var expandedStackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .vertical
stackView.isHidden = true
stackView.addArrangedSubview(dogButton)
stackView.addArrangedSubview(catButton)
return stackView
}()
lazy var containerStackView: UIStackView = {
let stackView = UIStackView()
stackView.axis = .vertical
stackView.addArrangedSubview(expandedStackView)
stackView.addArrangedSubview(menuButton)
return stackView
}()
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment