HomeView.swift 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // HomeView.swift
  3. // app
  4. //
  5. // Created by Iñigo Valentin on 21/11/16.
  6. // Copyright © 2016 Margolariak. All rights reserved.
  7. //
  8. import Foundation
  9. import UIKit
  10. class HomeView: UIView {
  11. @IBOutlet weak var scrollView: UIScrollView!
  12. @IBOutlet weak var container: UIView!
  13. @IBOutlet weak var locationSection: Section!
  14. @IBOutlet weak var lablancaSection: Section!
  15. @IBOutlet weak var futureActivitiesSection: Section!
  16. @IBOutlet weak var blogSection: Section!
  17. @IBOutlet weak var gallerySection: Section!
  18. @IBOutlet weak var pastActivitiesSection: Section!
  19. @IBOutlet weak var socialSection: Section!
  20. required init?(coder aDecoder: NSCoder) {
  21. print("HomeView: init")
  22. super.init(coder: aDecoder)
  23. Bundle.main.loadNibNamed("HomeView", owner: self, options: nil)
  24. self.addSubview(container)
  25. container.frame = self.bounds
  26. //Set titles
  27. locationSection.setTitle(text: "Encuentranos")
  28. lablancaSection.setTitle(text: "La Blanca")
  29. futureActivitiesSection.setTitle(text: "Proximas actividades")
  30. blogSection.setTitle(text: "Ultimos posts")
  31. gallerySection.setTitle(text: "Ultimas fotos")
  32. pastActivitiesSection.setTitle(text: "Ultimas actividades")
  33. socialSection.setTitle(text: "Siguenos")
  34. //Always at the end: update scrollview
  35. //var contentRect: CGRect = CGRect.zero;
  36. //for view in scrollView.subviews {
  37. // contentRect = contentRect.union(view.frame);
  38. //}
  39. //self.scrollView.contentSize = contentRect.size;
  40. var h: Int = 0
  41. for view in scrollView.subviews {
  42. //contentRect = contentRect.union(view.frame);
  43. h = h + Int(view.frame.height) + 30 //Why 30?
  44. print("curh: \(h)")
  45. }
  46. self.scrollView.contentSize.height = CGFloat(h);
  47. //let lastView : Section! = scrollView.subviews.last as! Section!
  48. //let height = lastView.frame.size.height
  49. //let pos = lastView.frame.origin.y
  50. //let sizeOfContent = height + pos + 10
  51. //scrollView.contentSize.height = sizeOfContent
  52. }
  53. }