0

我想知道是否有人可以提供帮助,我正在尝试调整我的应用程序以使其能够识别 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];
     }
}
4

2 回答 2

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);
于 2013-03-16T04:05:30.280 回答
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];
    }
于 2013-03-16T06:54:40.523 回答