IOS SDK

This document assumes that you understand the basic terms of IOS app development

Step 1: Create a UIButton for the floating button

  let fabButton: UIButton = {
            let button = UIButton()
            button.setImage(UIImage(systemName: "plus.circle.fill"), for: .normal)
            button.tintColor = .white
            button.backgroundColor = .systemBlue
            button.layer.cornerRadius = 28 // Adjust the size as needed
            button.layer.shadowColor = UIColor.black.cgColor
            button.layer.shadowOffset = CGSize(width: 0, height: 3)
            button.layer.shadowRadius = 3
            button.layer.shadowOpacity = 0.7
            button.translatesAutoresizingMaskIntoConstraints = false
            return button
        }()

Step 2: Add the floating button to the view hierarchy and the FAB to the view controller's view

  override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationController?.setNavigationBarHidden(false, animated: false)
        let myURL = URL(string:"https://shorts-stg.saleassist.ai/source/e7a1dac1-56d1-445c-b1e3-bd6a487cda6b/")
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)
        
        // Add the floating button to the view hierarchy
        // Add the FAB to the view controller's view
                view.addSubview(fabButton)
                // Configure FAB constraints to position it at the bottom-right corner
                fabButton.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -16).isActive = true
                fabButton.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor, constant: -16).isActive = true
                fabButton.widthAnchor.constraint(equalToConstant: 56).isActive = true
                fabButton.heightAnchor.constraint(equalTo: 
                fabButton.widthAnchor).isActive = true
                // Add a tap action to the FAB
                fabButton.addTarget(self, action: #selector(fabTapped), for: .touchUpInside)
 
    }

    @objc func fabTapped() {
        
        let  newViewController:UIViewController = (self.storyboard?.instantiateViewController(withIdentifier:  "NewViewController") as? NewViewController)!
        self.navigationController?.pushViewController(newViewController, animated: true)
        
        }

Last updated

Was this helpful?