curlUp和curlDown动画从一个视图控制器到另一个视图控制器

时间:2016-06-14 18:33:03

标签: ios uiviewcontroller uiviewanimationtransition

我试图通过使用页面卷曲动画从一个视图控制器转到另一个视图控制器;但是当我的第二个控制器加载时,它会隐藏它的集合视图。这是我的代码:

OffersVC *Offers = [[OffersVC alloc]init];
    Offers = [self.storyboard instantiateViewControllerWithIdentifier:@"Offers"];
    [UIView beginAnimations:@"flipview" context:nil];
    [UIView setAnimationDuration:2];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
    [self.view addSubview:Offers.view];

    [UIView commitAnimations];

1 个答案:

答案 0 :(得分:-1)

尝试添加动画,如下所示,然后检查

class TabBarController: UITabBarController, UITableViewDelegate, UITableViewDataSource {



  var tabBarItems: [UIViewController] = []
  var areMessagesVisible: Bool = false

  var titleForTabBars: [String] = ["Home", "Inbox", "Rewards", "My Card", "Locations", "My Profile", "Account Activity", "Invite Friends",  "About Us", "Settings", "Help"]

  var iconNames: [String] = ["Glass",  "Mail Tab Bar Icon", "Rewards Tab Bar Icon", "TabBar card icon", "Locations Tab Bar Icon", "", "", "","","",""]

  var controllersStoryboardId: [String] = ["homeNavController",  "inboxNavController", "rewardsNavController", "cardNavController", "locationsNavController", "myProfileNavController", "accountActivityNavController", "inviteFriendsNavController", "aboutUsNavController",  "settingsNavController", "helpNavController" ]



  // to manage moreTableView
  var moreTableView: UITableView = UITableView()
  var currentTableViewDelegate: UITableViewDelegate?




  override func viewDidLoad() {
    super.viewDidLoad()

    self.customizeMoreTableView()
    //to REMOVE
    areMessagesVisible = true

    if !areMessagesVisible{
      self.titleForTabBars.removeAtIndex(4)
      self.controllersStoryboardId.removeAtIndex(4)
      self.iconNames.removeAtIndex(4)
    }

    for i in 0 ..< controllersStoryboardId.count{
      tabBarItems.append(UIStoryboard(name: "Main", bundle: NSBundle.mainBundle()).instantiateViewControllerWithIdentifier(controllersStoryboardId[i]) as? UINavigationController ?? UINavigationController())
    }


    // change background image
    let backgroundImageView = UIImageView(image: UIImage(named: "Blank Settings"))
    backgroundImageView.frame = view.frame
    backgroundImageView.contentMode = .ScaleAspectFill
    moreNavigationController.topViewController?.view.addSubview(backgroundImageView)
    moreNavigationController.topViewController?.view.sendSubviewToBack(backgroundImageView)

    let backgroundImageView2 = UIImageView(image: UIImage(named: "background3"))
    backgroundImageView2.frame = view.frame
    backgroundImageView2.contentMode = .ScaleAspectFill
    moreNavigationController.topViewController?.view.addSubview(backgroundImageView2)
    moreNavigationController.topViewController?.view.sendSubviewToBack(backgroundImageView2)


    //change nav bar color
        moreNavigationController.navigationBar.barStyle = UIBarStyle.BlackOpaque
        moreNavigationController.navigationBar.barTintColor = UIColor.blackColor()
        moreNavigationController.navigationBar.tintColor = UIColor.whiteColor()

     }




  override func viewWillAppear(animated: Bool) {

    for i in 0 ..< tabBarItems.count{
      tabBarItems[i].tabBarItem = UITabBarItem(title: titleForTabBars[i], image: UIImage(named: iconNames[i]), selectedImage: UIImage(named: iconNames[i]))
    }
    self.viewControllers = tabBarItems
  }


  func customizeMoreTableView(){
    moreTableView = self.moreNavigationController.topViewController!.view as? UITableView ?? UITableView()
    currentTableViewDelegate = moreTableView.delegate;
    moreTableView.delegate = self
    moreTableView.dataSource = self;
    moreTableView.registerClass(MoreTableViewCell.self, forCellReuseIdentifier: "MoreTableViewCell")

  }


  func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return 50
  }


  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let moreCell  = tableView.dequeueReusableCellWithIdentifier("MoreTableViewCell", forIndexPath: indexPath) as? MoreTableViewCell ?? MoreTableViewCell()

    moreCell.textLabel?.text = titleForTabBars[indexPath.row + 4]
    moreCell.textLabel?.textColor = UIColor.whiteColor()
    moreCell.imageView?.image = UIImage(named: iconNames[indexPath.row + 4])
    moreCell.backgroundColor = UIColor.clearColor()

    return moreCell
  }


  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return titleForTabBars.count - 4

  }


  func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    currentTableViewDelegate?.tableView!(tableView, didSelectRowAtIndexPath: indexPath)
  }

}