【Swift】 플로팅 액션 버튼을 만드는 방법
구현 이미지
TableViewCell 위에 떠 있는 디자인으로 슬라이드해도 고정되도록 구현합니다.

Storyboard
우선 button만을 두고 AutoLayout을 붙입니다.


그 위에 TableView,TableViewCell을 화면 가득 놓습니다. TableViewCell의 Identifier를 Cell로 설정합시다.

소스 코드
ViewController.Swift
import UIKit
class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
    @IBOutlet weak var tableView: UITableView!
    @IBOutlet weak var button: UIButton!
//    TableView
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 30
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
        return cell
    }
//    FAB
    var startingFrame : CGRect!
    var endingFrame : CGRect!
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        if (scrollView.contentOffset.y >= (scrollView.contentSize.height - scrollView.frame.size.height)) && self.button.isHidden {
         self.button.isHidden = false
         self.button.frame = startingFrame 
         UIView.animate(withDuration: 1.0) {
          self.button.frame = self.endingFrame
         }
        }
    }
    func configureSizes() {
        let screenSize = UIScreen.main.bounds
        let screenWidth = screenSize.width
        let screenHeight = screenSize.height
        startingFrame = CGRect(x: 0, y: screenHeight+100, width: screenWidth, height: 100)
        endingFrame = CGRect(x: 0, y: screenHeight-100, width: screenWidth, height: 100)
    }
    override func viewDidLoad() {
        super.viewDidLoad()
//        buttonを角丸にする
        button.layer.cornerRadius = 32
    }
}
Reference
이 문제에 관하여(【Swift】 플로팅 액션 버튼을 만드는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/oskmr/items/2cc139d20ee1ef0da22f텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)