A
A
Aleksandr Govorukhin2018-06-23 23:16:25
iOS
Aleksandr Govorukhin, 2018-06-23 23:16:25

How to scroll subview in tableview?

Actually the question itself in the title created the button:

let button = UIButton(frame: CGRect(x: view.frame.maxX - 65, y: view.frame.maxY - 65, width: 50, height: 50))
        button.setTitleColor(.gray, for: .normal)
        button.backgroundColor = UIColor(red: 204/255, green: 0/255, blue: 102/255, alpha: 1)
        button.setImage(UIImage(named: "backButton")?.resize(targetSize: CGSize(width: 35, height: 35)), for: .normal)
        button.layer.borderColor = UIColor.white.cgColor
        button.layer.borderWidth = 1
        button.layer.cornerRadius = button.frame.width / 2
        button.clipsToBounds = true
        button.addTarget(self, action: #selector(back), for: .touchUpInside)
        view.addSubview(button)

And it is necessary that when scrolling the page, the button remains in the same place (in this case, bottom right). How to do it?
A photo
5b2eaa6ee7b62597312346.png5b2eaa73cffdd633995106.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
doublench21, 2018-06-23
@SnapSh0t

button.translatesAutoresizingMaskIntoConstraints = false
if #available(iOS 11.0, *) {
     button.rightAnchor.constraint(equalTo: tableView.safeAreaLayoutGuide.rightAnchor, constant: -10).isActive = true
     button.bottomAnchor.constraint(equalTo: tableView.safeAreaLayoutGuide.bottomAnchor, constant: -10).isActive = true
}

B
briahas, 2018-07-04
@briahas

Probably - do not add a subview button to the table view. Let it lie on top of the table and then it will not scroll. Or did I not understand the question?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question