2013-03-16 68 views
0

我想知道是否有人可以协助我,我正在尝试调整我的应用程序,以便它可以识别iPhone 5的全屏幕,但它现在可以在其他屏幕上正常工作,但是我的初始屏幕我遇到了问题,因为我淡入淡出顶部和底部的酒吧,顶部工作正常,但底部没有,任何人都可以帮助我的代码来帮助我在iPhone 5上工作吗?至于现在,酒吧是对iPhone 5的屏幕上太高,不淡出了人们的看法...iPhone 5隐藏在视图中的酒吧布局

- (void)barwillGo 
{ 

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { 
    [UIView animateWithDuration:0.5f 
          delay:0.0f 
         options:UIViewAnimationCurveEaseIn 
        animations:^{ 

         CGRect top = CGRectMake(0, -51, 320, 50); 

         if (CGRectEqualToRect(topBar.frame,top)) 
         { 

          [topBar setFrame:CGRectMake(0, 0, 320, 50)]; 
          [bottomBar setFrame:CGRectMake(0, 430, 320, 50)]; 

          } 

         else { 
          [topBar setFrame:CGRectMake(0, -51, 320, 50)]; 
          [bottomBar setFrame:CGRectMake(0, 481, 320, 50)]; 
         } 


        } 
        completion:nil]; 
    } 
    else { 
     [UIView animateWithDuration:0.5f 
           delay:0.0f 
          options:UIViewAnimationCurveEaseIn 
          animations:^{ 

           CGRect top = CGRectMake(0, -51, 768, 50); 

           if (CGRectEqualToRect(topBar.frame,top)) 
           { 

            [topBar setFrame:CGRectMake(0, 0, 768, 50)]; 
            [bottomBar setFrame:CGRectMake(0, 974, 768, 50)]; 

           } 

           else { 
            [topBar setFrame:CGRectMake(0, -51, 768, 50)]; 
            [bottomBar setFrame:CGRectMake(0, 1025, 768, 50)]; 
           } 


          } 
          completion:nil]; 
    } 
} 

回答

1

你硬编码的bottomBar的的CGRect值3.5英寸的屏幕尺寸。

尝试这样的事情你的第一个动画块中:

CGRect bounds = topView.superview.bounds; 
CGFloat topRectY, bottomRectY; 
if(topBar.frame.origin.y == -50){ 
    topRectY = 0; 
    bottomRectY = bounds.size.height - 50; 
} else { 
    topRectY = -50; 
    bottomRectY = bounds.size.height; 
} 
topBar.frame = CGRectMake(0, topRectY, bounds.size.width, 50); 
bottomBar.frame = CGRectMake(0, bottomRectY, bounds.size.width, 50); 
+0

精湛,感谢你,是一个很好的解决方案 - 真的再次感谢你帮我,谢谢:) – user1695971 2013-03-16 20:58:35

0
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; 

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { 
     [UIView animateWithDuration:0.5f 
           delay:0.0f 
          options:UIViewAnimationCurveEaseIn 
         animations:^{ 

          CGRect top = CGRectMake(0, -51, 320, 50); 

          if (CGRectEqualToRect(topBar.frame,top)) 
          { 

           [topBar setFrame:CGRectMake(0, 0, 320, 50)]; 
           [bottomBar setFrame:CGRectMake(0, 430, 320, 50)]; 

          } 

          else { 
//check device iphone5 or not 
           if (screenHeight != 568.0f) { 
            [topBar setFrame:CGRectMake(0, -51, 320, 50)]; 
            [bottomBar setFrame:CGRectMake(0, 481, 320, 50)]; 
           } 
           else 
           { 
            [topBar setFrame:CGRectMake(0, -51, 320, 50)]; 
            [bottomBar setFrame:CGRectMake(0, 569, 320, 50)]; 
           } 
          } 


         } 
         completion:nil]; 
    } 
+0

NANNAV嗨 - 这种解决方案不过,iPhone 5上的酒吧的起始位置进一步上升,尼克C解决方案工作,但我也要感谢你的帮助。 – user1695971 2013-03-16 20:59:17