Posted By


iswear_wxp on 04/12/10

Tagged


Statistics


Viewed 160 times
Favorited by 0 user(s)

iPhone官方SDK:如何隐藏UINavigationBar


/ Published in: iPhone
Save to your folder(s)



Copy this code and paste it in your HTML
  1. 我在写电子书 Tread 的时候 , 想实现自动隐藏 UINavigationBar, 以达到 iPhone 上面浏览 Photo 的效果 . 当时 NavigationBar 在 UINavigationController 里面是 private 的 , 无法把她变成透明 . 最后只好把它
  2.   
  3.  
  4. 在写电子书Tread的时候,想实现自动隐藏UINavigationBar,以达到iPhone上面浏览Photo的效果.
  5.  
  6. 当时NavigationBar在UINavigationController里面是private的,无法把她变成透明.
  7.  
  8.  
  9.  
  10. 最后只好把它"推出"view 外面,来达到隐藏的目的.
  11.  
  12. 在Beta1一直到Beta4,是这样写的
  13.  
  14.  
  15. [UIView beginAnimations:nil context:NULL];
  16.  
  17. [UIView setAnimationDuration:0.5];
  18.  
  19.  
  20.  
  21. CGRect viewFrame = self.navigationController.view.bounds;
  22.  
  23. //CGPoint touchPoint1 = self.navigationController.view.center;
  24.  
  25. if (viewIsUp) {
  26.  
  27. viewFrame.origin.y -= 25;
  28.  
  29. viewFrame.size.height -= 50;
  30.  
  31. viewIsUp = NO;
  32.  
  33. } else {
  34.  
  35. viewFrame.origin.y += 25;
  36.  
  37. viewFrame.size.height += 50;
  38.  
  39. viewIsUp = YES;
  40.  
  41. }
  42.  
  43. self.navigationController.view.bounds =viewFrame;
  44.  
  45. [UIView commitAnimations];
  46.  
  47.  
  48. 刚发布的Beta5,这个功能已经加在API里面了
  49.  
  50. 现在变成
  51.  
  52. if (viewIsUp) {
  53.  
  54. [self.navigationController setNavigationBarHidden:NO animated:YES];
  55.  
  56. viewIsUp = NO;
  57.  
  58. } else {
  59.  
  60. [self.navigationController setNavigationBarHidden:YES animated:YES];
  61.  
  62. viewIsUp = YES;
  63.  
  64. }

URL: http://www.cocoachina.com/iphonedev/sdk/2009/0611/192.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.