Advertisement
Guest User

infoDetailView

a guest
Apr 13th, 2016
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 2.16 KB | None | 0 0
  1. //
  2. //  ViewController.swift
  3. //  test
  4. //
  5. //  Created by Alessandro Ornano on 22/03/16.
  6. //  Copyright © 2016 Alessandro Ornano. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10.  
  11. class ViewController: UIViewController{
  12.  
  13.     @IBOutlet var infoDetailView: UIView! // Connected to the view in the SceneDock
  14.    
  15.     override func viewDidLoad() {
  16.         super.viewDidLoad()
  17.        
  18.         // Cut other vDL code that isn't relevant
  19.        
  20.         setupInfoView()
  21.     }
  22.    
  23.     func setupInfoView() {
  24.         infoDetailView.alpha = 0.0
  25.         view.addSubview(infoDetailView)
  26.         updateInfoViewRect(infoDetailView.superview!.bounds.size)
  27.     }
  28.    
  29.     func updateInfoViewRect(size:CGSize) {
  30.         let viewRect = CGRect(origin: CGPointZero, size: size)
  31.        
  32.         infoDetailView.frame = viewRect
  33.         infoDetailView.bounds = viewRect
  34.        
  35.         infoDetailView.layoutIfNeeded()
  36.         infoDetailView.setNeedsDisplay()
  37.     }
  38.    
  39.     override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
  40.         super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
  41.         updateInfoViewRect(size)
  42.     }
  43.    
  44.     func hideInfoView() {
  45.        // AFLog.enter(thisClass)
  46.         UIView.animateWithDuration(
  47.             2.0,
  48.             animations:
  49.             {
  50.                 self.infoDetailView.alpha = 0.0
  51.             },
  52.             completion:
  53.             { (finished) in
  54.                 return true
  55.             }
  56.         )
  57.         //AFLog.exit(thisClass)
  58.     }
  59.    
  60.     func showInfoView() {
  61.         //AFLog.enter(thisClass)
  62.         UIView.animateWithDuration(
  63.             2.0,
  64.             animations:
  65.             {
  66.                 self.infoDetailView.alpha = 0.75
  67.             },
  68.             completion:
  69.             { (finished) in
  70.                 return true
  71.             }
  72.         )
  73.         //AFLog.exit(thisClass)
  74.     }
  75.    
  76.     // MARK: - IBActions
  77.    
  78.     @IBAction func openInfoView(sender: UIButton) {
  79.         showInfoView()
  80.     }
  81.    
  82.     @IBAction func closeInfoView(sender: UIButton) {
  83.         hideInfoView()
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement