简体   繁体   English

UINavigationBar具有异型背景

[英]UINavigationBar with shaped background

I'm trying to make a custom UINavigationBar, but the problem is that my background image has a curve in it, and its little bit larger than default navigation bar. 我正在尝试制作一个自定义UINavigationBar,但问题是我的背景图像中有一条曲线,并且它比默认导航栏稍大。 When I try to set background image and change navigation bar size, its just scales image as a rectangle. 当我尝试设置背景图像并更改导航栏大小时,它只是将图像缩放为矩形。 Any ideas? 有任何想法吗?

Bar: 酒吧: 导航栏背景

Override 覆写

- (CGSize) sizeThatFits:(CGSize)size  {
  return CGSizeMake(custom_width, custom_height);
}

in order to return the size for your custom navigation bar. 为了返回您的自定义导航栏的大小。

Note that if you use a height that is not a multiple of 4, it will cause trouble if you hide and then show the navigation bar at any point (it gets shifted by 1 pixel from the top) 请注意,如果您使用的高度不是4的倍数,则在隐藏并显示导航栏的任何点时都会造成麻烦(它从顶部偏移1个像素)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM