swift vertical pager code example
Example 1: swift add horizontal line uiview programmatically
let path = UIBezierPath()
path.move(to: CGPoint(x: 10, y: 10))
path.addLine(to: CGPoint(x: 100, y: 100))
let shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.strokeColor = UIColor.blue.cgColor
shapeLayer.fillColor = UIColor.clear.cgColor
shapeLayer.lineWidth = 3
view.layer.addSublayer(shapeLayer)
Example 2: horizontal slide segue swift
import UIKit
class firstCustomSegue: UIStoryboardSegue {
override func perform() {
let initalView = self.source.view as UIView!
let destinationView = self.destination.view as UIView!
let screenHeight = UIScreen.main.bounds.size.height
let screenWidth = UIScreen.main.bounds.size.width
initalView?.frame = CGRect(x: 0, y: 0, width: screenWidth, height: screenHeight)
destinationView?.frame = CGRect(x: screenWidth, y: 0, width: screenWidth, height: screenHeight)
let appWindow = UIApplication.shared.keyWindow
appWindow?.insertSubview(destinationView!, aboveSubview: initalView!)
UIView.animate(withDuration: 0.4, animations: {
initalView?.frame = (initalView?.frame.offsetBy(dx: -screenWidth, dy: 0))!
destinationView?.frame = (destinationView?.frame.offsetBy(dx: -screenWidth, dy: 0))!
}) { (Bool) in
self.source.present(self.destination, animated: false, completion: nil)
}
}
}