From a1475356a4659ab9f3fd910f77bd83542b9e4c63 Mon Sep 17 00:00:00 2001 From: ylzheng Date: Mon, 2 Nov 2015 21:51:48 +0800 Subject: [PATCH] try fix top margin issue --- librx/Base.lproj/Main.storyboard | 10 +++++----- librx/ContainerViewController.swift | 4 ---- librx/DashViewController.swift | 15 ++++++--------- librx/RGPageViewController.swift | 27 ++++++++++++--------------- librx/StorysTableViewController.swift | 14 +------------- 5 files changed, 24 insertions(+), 46 deletions(-) diff --git a/librx/Base.lproj/Main.storyboard b/librx/Base.lproj/Main.storyboard index 6c77f27..a546f47 100644 --- a/librx/Base.lproj/Main.storyboard +++ b/librx/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -143,7 +143,7 @@ - + @@ -660,7 +660,7 @@ - + @@ -890,7 +890,7 @@ - + @@ -1612,7 +1612,7 @@ - + diff --git a/librx/ContainerViewController.swift b/librx/ContainerViewController.swift index 0e8a6f8..91ad561 100644 --- a/librx/ContainerViewController.swift +++ b/librx/ContainerViewController.swift @@ -21,10 +21,6 @@ class ContainerViewController: UIPageViewController { let staticProfileTableViewController = self.storyboard?.instantiateViewControllerWithIdentifier("GraphsUIViewController") as! GraphsUIViewController - myPostStoriesTableViewController.isInlineOfContainer = true - likeProfileTableViewController.isInlineOfContainer = true - faviroteProfileTableViewController.isInlineOfContainer = true - if self.isMe { likeProfileTableViewController.postSection = .Liked myPostStoriesTableViewController.postSection = .MyPostTimeLine diff --git a/librx/DashViewController.swift b/librx/DashViewController.swift index 54cd0c7..ab02f5e 100644 --- a/librx/DashViewController.swift +++ b/librx/DashViewController.swift @@ -14,7 +14,7 @@ class DashViewController: RGPageViewController, RGPageViewControllerDataSource, @IBOutlet weak var shareButton: UIBarButtonItem! private var loginStateChange: LoginStateHandler? - + var menu: NSArray = ["信息流", "最新", "热门"] var storysViewController1: StorysTableViewController! var storysViewController2: StorysTableViewController! @@ -26,6 +26,10 @@ class DashViewController: RGPageViewController, RGPageViewControllerDataSource, self.navigationController?.navigationBar.tintColor = UIColor.whiteColor() self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()] + self.navigationController?.navigationBarHidden = false + + self.pager.view.bounds = CGRectInset((parentViewController?.view.frame)!, 0, 52.0) + self.datasource = self self.delegate = self @@ -43,22 +47,15 @@ class DashViewController: RGPageViewController, RGPageViewControllerDataSource, self.storysViewController1 = storyboard.instantiateViewControllerWithIdentifier("StoriesTableViewController") as! StorysTableViewController self.storysViewController1.postSection = .HotTimeLine - self.storysViewController1.isInlineOfContainer = false self.storysViewController2 = storyboard.instantiateViewControllerWithIdentifier("StoriesTableViewController") as! StorysTableViewController self.storysViewController2.postSection = .RecentTimeLine - self.storysViewController2.isInlineOfContainer = false - + self.storysViewController3 = storyboard.instantiateViewControllerWithIdentifier("StoriesTableViewController") as! StorysTableViewController self.storysViewController3.postSection = .Default - self.storysViewController3.isInlineOfContainer = false } - override func viewWillLayoutSubviews() { - super.viewWillLayoutSubviews() - } - func numberOfPagesForViewController(pageViewController: RGPageViewController) -> Int { return menu.count } diff --git a/librx/RGPageViewController.swift b/librx/RGPageViewController.swift index 1698d63..428e4e4 100644 --- a/librx/RGPageViewController.swift +++ b/librx/RGPageViewController.swift @@ -60,7 +60,7 @@ class RGPageViewController: UIViewController, UIPageViewControllerDataSource, UI } var tabIndicatorWidthOrHeight: CGFloat { get { - return 1.0 + return 2.0 } } var tabIndicatorColor: UIColor { @@ -75,7 +75,7 @@ class RGPageViewController: UIViewController, UIPageViewControllerDataSource, UI } var tabStyle: RGTabStyle { get { - return .None + return .InactiveFaded } } // MARK: - Tabbar @@ -433,7 +433,7 @@ class RGPageViewController: UIViewController, UIPageViewControllerDataSource, UI switch tabbarPosition { case .Top, .Bottom: - newTabRect.origin.x -= tabMargin / 2.0 + newTabRect.origin.x -= (index == 0 ? tabMargin : tabMargin / 2.0) newTabRect.size.width += tabMargin case .Left, .Right: newTabRect.origin.y -= tabMargin / 2.0 @@ -473,7 +473,7 @@ class RGPageViewController: UIViewController, UIPageViewControllerDataSource, UI switch tabbarPosition { case .Top, .Bottom: - newTabRect.origin.x -= tabMargin / 2.0 + newTabRect.origin.x -= (index == 0 ? tabMargin : tabMargin / 2.0) newTabRect.size.width += tabMargin case .Left, .Right: newTabRect.origin.y -= tabMargin / 2.0 @@ -514,24 +514,21 @@ class RGPageViewController: UIViewController, UIPageViewControllerDataSource, UI private func updatePager(index: Int) { if let vc: UIViewController = viewControllerAtIndex(index) { - weak var weakSelf: RGPageViewController? = self - weak var weakPager: UIPageViewController? = pager - if index == currentPageIndex { - pager.setViewControllers([vc], direction: .Forward, animated: false, completion: { (Bool) -> Void in - weakSelf!.animatingToTab = false + pager.setViewControllers([vc], direction: .Forward, animated: false, completion: { [weak self] (Bool) -> Void in + self?.animatingToTab = false }) } else if !(index + 1 == currentPageIndex || index - 1 == currentPageIndex) { - pager.setViewControllers([vc], direction: index < currentPageIndex ? .Reverse : .Forward, animated: true, completion: { (Bool) -> Void in - weakSelf!.animatingToTab = false + pager.setViewControllers([vc], direction: index < currentPageIndex ? .Reverse : .Forward, animated: true, completion: { [unowned self] (Bool) -> Void in + self.animatingToTab = false - dispatch_async(dispatch_get_main_queue(), { - weakPager!.setViewControllers([vc], direction: index < weakSelf!.currentPageIndex ? .Reverse : .Forward, animated: false, completion: nil) + dispatch_async(dispatch_get_main_queue(), { [unowned self] in + self.pager.setViewControllers([vc], direction: index < self.currentPageIndex ? .Reverse : .Forward, animated: false, completion: nil) }) }) } else { - pager.setViewControllers([vc], direction: index < currentPageIndex ? .Reverse : .Forward, animated: true, completion: { (Bool) -> Void in - weakSelf!.animatingToTab = false + pager.setViewControllers([vc], direction: index < currentPageIndex ? .Reverse : .Forward, animated: true, completion: { [weak self] (Bool) -> Void in + self?.animatingToTab = false }) } diff --git a/librx/StorysTableViewController.swift b/librx/StorysTableViewController.swift index 8759dfc..015ae00 100644 --- a/librx/StorysTableViewController.swift +++ b/librx/StorysTableViewController.swift @@ -22,8 +22,7 @@ class StorysTableViewController: UITableViewController { // mark : data private var posts:[Post] = [] - - var isInlineOfContainer = false + var postSection : PostsLoader.PostSection = .Default { didSet { postsLoader = PostsLoader(postSection) @@ -40,7 +39,6 @@ class StorysTableViewController: UITableViewController { self.refreshControl?.tintColor = UIColor(red: 46/255.0, green: 204/255.0, blue: 113/255.0, alpha: 1.0) self.refreshControl?.addTarget(self, action: "refresh", forControlEvents: .ValueChanged) self.refreshControl?.backgroundColor = UIColor(white: 0.97, alpha: 1) - self.tableView.addSubview(refreshControl!) self.tableView.separatorColor = UIColor(red:240.0/255.0, @@ -50,12 +48,6 @@ class StorysTableViewController: UITableViewController { self.tableView.rowHeight = UITableViewAutomaticDimension self.tableView.backgroundColor = UIColor(white: 0.97, alpha: 1) - // Table View 站位 - let tableFooterView:UIView = UIView() - tableFooterView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 44) - tableFooterView.backgroundColor = UIColor.whiteColor() - self.tableView.tableFooterView = tableFooterView - // mark start refreshing self.refreshControl?.beginRefreshing() @@ -70,10 +62,6 @@ class StorysTableViewController: UITableViewController { // reload data when view did appear self.tableView.reloadData() - if !isInlineOfContainer { - self.tableView.contentInset.top = 160 - } - // load data at first time if firstTime { refresh()