skip to Main Content

I want to open a segue, but only on a half screen, the rest I want to be an ImageView, I tried searching up segue padding, but couldn’t find what I was looking for, In figma, I’ve added an IOS extension, where I got an asset( picture below ), what I see on picture is a view opened on half screen, is there any other way beside UIView to achive my end result?

enter image description here

2

Answers


  1. For half view controller we have to set height and width.

    HalfViewController.swift

        import Foundation
        import UIKit
        
        class HalfSizePresentationController: UIPresentationController {
            override var frameOfPresentedViewInContainerView: CGRect {
                guard let bounds = containerView?.bounds else { return .zero }
                return CGRect(x: 0, y: bounds.height / 2, width: bounds.width, height: bounds.height / 2)
            }
        }
    

    Now call HalfViewController.swift in view controller

      @IBAction func addGoalButton(_ sender: Any) {
            movetoAddgaolModal()
                }
    func movetoAddgaolModal(){
            let storyboard = UIStoryboard(name: "Stopwatch", bundle: nil)
                    let pvc = storyboard.instantiateViewController(withIdentifier: "TimersetViewController") as! TimersetViewController
                    pvc.modalPresentationStyle = .custom
                    pvc.transitioningDelegate = self
                    present(pvc, animated: true)
        }
                func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
                    return HalfSizePresentationController(presentedViewController: presented, presenting: presentingViewController)
                }
    
    Login or Signup to reply.
  2. I’m always using this pod FittedSheets

            let storyboard = UIStoryboard(name: "Order", bundle: nil)
            let vc = storyboard.instantiateViewController(withIdentifier: "PaymentTypeVC") as! PaymentTypeVC
            let sheetVC = Utils.createSheetController(vc: vc, sizes: [.fixed(320)])
            sheetVC.modalPresentationStyle = .overFullScreen
            present(sheetVC, animated: true, completion: nil)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search