0

I have a created a UIView like this:

class miniPlayerBar: UIView {

    lazy var miniPlayerButton: UIButton = {
        let button = UIButton(type: .system)
        button.backgroundColor = .orange
        button.setTitle("Open", for: .normal)
        button.setTitleColor(.white, for: .normal)
        button.addTarget(self, action: #selector(presentFullPlayer), for: .touchUpInside)
        button.layer.cornerRadius = 5
        return button
    }()

    override init(frame: CGRect) {
        super.init(frame: CGRect(x: 0, y: 0, width: 320, height: 50))
        addSubview(self.miniPlayerButton)

        _ = miniPlayerButton.anchor(nil, left: leftAnchor, bottom: bottomAnchor, right: rightAnchor, topConstant: 0, leftConstant: 0, bottomConstant: 49, rightConstant: 0, widthConstant: 0, heightConstant: 26)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    func presentFullPlayer() {

    }

I want to be able to show this view on top of a view controller. How would I get this to show in any view controller (tableview, collectionview, UIViewController)?

Cœur
  • 37,241
  • 25
  • 195
  • 267

0 Answers0