我制作了导航栏的子类。在那里我设置了一个背景图像,我想禁用剪辑,因为我的图像有一些阴影和一个高于导航栏的箭头。
在 iOS 6 和 5 中,当我在 Xcode 的 Interface Builder 中删除勾选 Clip Subviews 时,它可以完美运行。不幸的是,在 iOS7 中,背景图像总是被剪裁......我还尝试添加以下几行:
- (void) awakeFromNib
{
// Initialization code
UIImage *image = [UIImage imageNamed:@"tt_navigation_bar.png"];
if ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0) image = [UIImage imageNamed:@"tt_navigation_bar-ios7.png"];
[[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
NSDictionary *textTitleOptions = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"HelveticaNeue-Bold" size:21.0], UITextAttributeFont, [UIColor colorWithRed:255.0/255.0 green:109.0/255.0 blue:36.0/255.0 alpha:1], UITextAttributeTextColor, [UIColor clearColor], UITextAttributeTextShadowColor, nil];
[[UINavigationBar appearance] setTitleTextAttributes:textTitleOptions];
for (UIView *v in [self subviews]) {
NSLog(@"v: %@", v);
v.layer.masksToBounds = NO;
}
self.layer.masksToBounds = NO;
}