Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Code for MapKitView and Location based call out
- import UIKit
- import MapKit
- class ViewController: UIViewController {
- @IBOutlet var mapView: MKMapView!
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view.
- // setup the map's location and zoom factor
- let lattitude = 21.1702
- let longitude = 72.8311
- var mapRegion:MKCoordinateRegion = MKCoordinateRegion();
- mapRegion.center.latitude = lattitude;
- mapRegion.center.longitude = longitude;
- mapRegion.span.latitudeDelta = 0.5;
- mapRegion.span.longitudeDelta = 0.5;
- mapView.setRegion(mapRegion, animated: true)
- //For creating pin point (CallOut)
- let ant = MKPointAnnotation()
- ant.title="Where am I?...."
- ant.subtitle="I am at VNSGU...."
- ant.coordinate = CLLocationCoordinate2D(latitude: lattitude, longitude: longitude)
- mapView.addAnnotation(ant)
- }
- }
- //Code for Auto layout Constraint Animation
- import UIKit
- class ViewController: UIViewController {
- @IBOutlet var imageViewAni: UIImageView!
- var leftAnchor:NSLayoutConstraint?
- var rightAnchor:NSLayoutConstraint?
- //var topAnchor: NSLayoutConstraint?
- //var bottomAnchor: NSLayoutConstraint?
- // var widthAnchor: NSLayoutConstraint?
- //var heightAnchor: NSLayoutConstraint?
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view.
- imageViewAni.translatesAutoresizingMaskIntoConstraints = false
- imageViewAni.isUserInteractionEnabled = true
- imageViewAni.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(animate)))
- leftAnchor = imageViewAni.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor)
- leftAnchor?.isActive = true
- //topAnchor = imageViewAni.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor)
- //topAnchor?.isActive = true
- rightAnchor = imageViewAni.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor)
- //bottomAnchor = imageViewAni.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
- //steveJobsImageView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
- /*widthAnchor = imageViewAni.widthAnchor.constraint(equalToConstant: 100)
- widthAnchor?.isActive = true
- heightAnchor = imageViewAni.heightAnchor.constraint(equalToConstant: 100)
- heightAnchor?.isActive = true*/
- }
- @objc func animate(){
- print("Image is tapped")
- //animation code
- //topAnchor?.isActive = false
- leftAnchor?.isActive = false
- rightAnchor?.isActive = true
- /*bottomAnchor?.isActive = true
- rightAnchor?.constant = -16
- widthAnchor?.constant = 900
- heightAnchor?.constant = 200*/
- UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping:1, initialSpringVelocity: 1,options: .curveEaseOut,animations: {
- self.view.layoutIfNeeded()
- //self.imageViewAni?.frame = CGRect(x:200,y:0,width: 50,height: 50)
- },completion: nil)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement