我正在开发一个需要更改 UITabBar 高度的 iOS 应用程序。首先,我通过 tabbar 的 frame 属性对其进行了更改,但这并没有给出预期的结果,而且图标大小也非常小。因此,我编写了以下代码来更改标签栏的背景并增加其图标的大小。
for (UIView *view in ctrl.tabBar.subviews) {
if ([NSStringFromClass(view.class) isEqualToString:@"_UITabBarBackgroundView"]) {
[view removeFromSuperview];
CGRect frame = ctrl.tabBar.frame;
frame.origin = CGPointZero;
frame.size.height = floor(frame.size.height / 2);
UIView *background = [[UIView alloc] initWithFrame:frame];
background.backgroundColor = [UIColor colorWithRed:0.15 green:0.15 blue:0.15 alpha:1.0];
background.userInteractionEnabled = NO;
[ctrl.tabBar addSubview:background];
[ctrl.tabBar sendSubviewToBack:background];
[background release];
}
for (UIView *subview in view.subviews) {
if ([NSStringFromClass(subview.class) isEqualToString:@"UITabBarSwappableImageView"]) {
CGRect frame = subview.frame;
frame.size.height = 80;
subview.frame = frame;
subview.contentMode = UIViewContentModeCenter;
}
if ([NSStringFromClass(subview.class) isEqualToString:@"UITabBarButtonLabel"]) {
CGRect sFrame = subview.frame;
sFrame.size.height += diff;
subview.frame = sFrame;
}
}
}
所以我想确认一下,“这个代码是否可以安全地获得批准?”