Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. class AppDelegate: UIResponder, UIApplicationDelegate {
  2.  
  3. var window: UIWindow?
  4. var controller: SLPagingViewSwift!
  5. var nav: UINavigationController?
  6. var home: ViewController?
  7.  
  8. func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  9.  
  10.  
  11. window = UIWindow(frame: UIScreen.main.bounds)
  12. let orange = UIColor(red: 255/255, green: 69.0/255, blue: 0.0/255, alpha: 1.0)
  13. let gray = UIColor(red: 0.84, green: 0.84, blue: 0.84, alpha: 1.0)
  14.  
  15. let stb = UIStoryboard(name: "Main", bundle: nil)
  16. self.home = stb.instantiateViewController(withIdentifier: "ViewController") as? ViewController
  17. let vc2 = ViewController()
  18. vc2.view.backgroundColor = .red
  19. let vc3 = ViewController()
  20. vc3.view.backgroundColor = .blue
  21.  
  22.  
  23. var homeBtn = UIImage(named: "profile")
  24. homeBtn = homeBtn?.withRenderingMode(.alwaysTemplate)
  25. var vc2Btn = UIImage(named: "gear")
  26. vc2Btn = vc2Btn?.withRenderingMode(.alwaysTemplate)
  27. var vc3Btn = UIImage(named: "chat")
  28. vc3Btn = vc3Btn?.withRenderingMode(.alwaysTemplate)
  29.  
  30. let items = [UIImageView(image: homeBtn),
  31. UIImageView(image: vc2Btn),
  32. UIImageView(image: vc3Btn)]
  33.  
  34. let controllers = [self.home!,
  35. vc2,
  36. vc3] as [UIViewController]
  37.  
  38. self.controller = SLPagingViewSwift(items: items, controllers: controllers, showPageControl: false)
  39.  
  40. self.controller.pagingViewMoving = ({ subviews in
  41. if let imageViews = subviews as? [UIImageView] {
  42. for imgView in imageViews {
  43. var c = gray
  44. let originX = Double(imgView.frame.origin.x)
  45.  
  46. if (originX > 45 && originX < 145) {
  47. c = self.gradient(originX, topX: 46, bottomX: 144, initC: orange, goal: gray)
  48. }
  49. else if (originX > 145 && originX < 245) {
  50. c = self.gradient(originX, topX: 146, bottomX: 244, initC: gray, goal: orange)
  51. }
  52. else if(originX == 145){
  53. c = orange
  54. }
  55. imgView.tintColor = c
  56. }
  57. }
  58. })
  59.  
  60. self.nav = UINavigationController(rootViewController: self.controller)
  61. self.window?.rootViewController = self.nav
  62. self.window?.backgroundColor = UIColor.black
  63. self.window?.makeKeyAndVisible()
  64.  
  65. return true
  66.  
  67. }
  68.  
  69. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  70. let stb = UIStoryboard(name: "Main", bundle: nil)
  71. let vc = stb.instantiateViewController(withIdentifier: "SegueVC")
  72. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  73.  
  74. appDelegate.controller?.navigationController?.pushViewController(vc, animated: true)
  75. //appDelegate.nav?.pushViewController(vc, animated: true)
  76. }
  77.  
  78. appDelegate.controller?.navigationController?.pushViewController(vc, animated: true)
  79. //appDelegate.nav?.pushViewController(vc, animated: true)
  80.  
  81. self.nav = UINavigationController(rootViewController: self.controller)
  82. self.window?.rootViewController = self.nav
  83. self.window?.backgroundColor = UIColor.black
  84. self.window?.makeKeyAndVisible()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement