Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AppDelegate: UIResponder, UIApplicationDelegate {
- var window: UIWindow?
- var controller: SLPagingViewSwift!
- var nav: UINavigationController?
- var home: ViewController?
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
- window = UIWindow(frame: UIScreen.main.bounds)
- let orange = UIColor(red: 255/255, green: 69.0/255, blue: 0.0/255, alpha: 1.0)
- let gray = UIColor(red: 0.84, green: 0.84, blue: 0.84, alpha: 1.0)
- let stb = UIStoryboard(name: "Main", bundle: nil)
- self.home = stb.instantiateViewController(withIdentifier: "ViewController") as? ViewController
- let vc2 = ViewController()
- vc2.view.backgroundColor = .red
- let vc3 = ViewController()
- vc3.view.backgroundColor = .blue
- var homeBtn = UIImage(named: "profile")
- homeBtn = homeBtn?.withRenderingMode(.alwaysTemplate)
- var vc2Btn = UIImage(named: "gear")
- vc2Btn = vc2Btn?.withRenderingMode(.alwaysTemplate)
- var vc3Btn = UIImage(named: "chat")
- vc3Btn = vc3Btn?.withRenderingMode(.alwaysTemplate)
- let items = [UIImageView(image: homeBtn),
- UIImageView(image: vc2Btn),
- UIImageView(image: vc3Btn)]
- let controllers = [self.home!,
- vc2,
- vc3] as [UIViewController]
- self.controller = SLPagingViewSwift(items: items, controllers: controllers, showPageControl: false)
- self.controller.pagingViewMoving = ({ subviews in
- if let imageViews = subviews as? [UIImageView] {
- for imgView in imageViews {
- var c = gray
- let originX = Double(imgView.frame.origin.x)
- if (originX > 45 && originX < 145) {
- c = self.gradient(originX, topX: 46, bottomX: 144, initC: orange, goal: gray)
- }
- else if (originX > 145 && originX < 245) {
- c = self.gradient(originX, topX: 146, bottomX: 244, initC: gray, goal: orange)
- }
- else if(originX == 145){
- c = orange
- }
- imgView.tintColor = c
- }
- }
- })
- self.nav = UINavigationController(rootViewController: self.controller)
- self.window?.rootViewController = self.nav
- self.window?.backgroundColor = UIColor.black
- self.window?.makeKeyAndVisible()
- return true
- }
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- let stb = UIStoryboard(name: "Main", bundle: nil)
- let vc = stb.instantiateViewController(withIdentifier: "SegueVC")
- let appDelegate = UIApplication.shared.delegate as! AppDelegate
- appDelegate.controller?.navigationController?.pushViewController(vc, animated: true)
- //appDelegate.nav?.pushViewController(vc, animated: true)
- }
- appDelegate.controller?.navigationController?.pushViewController(vc, animated: true)
- //appDelegate.nav?.pushViewController(vc, animated: true)
- self.nav = UINavigationController(rootViewController: self.controller)
- self.window?.rootViewController = self.nav
- self.window?.backgroundColor = UIColor.black
- self.window?.makeKeyAndVisible()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement