我在选项卡栏视图控制器中具有自定义视图。我已经为自定义视图设置了自动化蒙版,但在iPhone 5屏幕上没有对齐。在iPhone 4屏幕上看起来不错。我在视图中有此代码确实加载了标签栏视图控制器的加载方法。
self.customBadge = [CustomBadge customBadgeWithString:[AppGlobals sharedInstance].badgeNumber];
self.customBadge.frame = CGRectMake(165, 420, self.customBadge.frame.size.width, self.customBadge.frame.size.width);
self.customBadge.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
[self.view addSubview: self.customBadge];
看来,您是根据塔巴尔(Tabbar)的整个视图(大多数屏幕)
根据坐标添加徽章尝试:
添加徽章作为塔巴尔视图本身的子视图(您可能需要将框架的y从420降低到约5-10):
[self.tabBar addSubview:self.customBadge];
如果(1)不适合您,则可以尝试硬编码的y值(这是不良练习,但是如果您被卡住 - 它应该有效):
#define VALUE_BY_SCREEN_HEIGHT(regular, longScreen) (([[UIScreen mainScreen] bounds].size.height <= 480.0) ? regular : longScreen)
...
self.customBadge.frame = CGRectMake(165, VALUE_BY_SCREEN_HEIGHT(420,508), self.customBadge.frame.size.width, self.customBadge.frame.size.width);