setBackgroundImage forBarMetrics +缩放填充?
从 iOS5 开始,您应该通过 setBackgroundImage forBarMetrics 设置工具栏或导航栏的背景图像。
在 iOS4 中,我使用:
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"NavigationBar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
在 iOS4 中,图像“缩放以填充”;在 iOS5 中,如果图像太小,则会重复图像。当您使用 setBackgroundImage forBarMetrics 时,有没有办法将行为设置为“scaleToFill”?
谢谢!
Since iOS5 you should set the backgroundimage of tool- or navigationbars via setBackgroundImage forBarMetrics.
In iOS4 I use:
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"NavigationBar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
In iOS4 the image "scales to fill" in iOS5 the image is repeated if it's to small. Is there a way to set the behaviour to "scaleToFill" when you use setBackgroundImage forBarMetrics?
Thx!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论