UINavigationBar有形状的背景 [英] UINavigationBar with shaped background

查看:107
本文介绍了UINavigationBar有形状的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个自定义UINavigationBar,但问题是我的背景图片有一个曲线,它的一点点比默认导航栏大。当我尝试设置背景图像和更改导航栏的大小,它只是缩放图像作为一个矩形。有任何想法?



酒吧:

解决方案

覆盖

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

,以返回自定义导航栏的大小。

请注意,如果您使用的高度不是4的倍数,那么如果您隐藏,然后在任何点显示导航栏(它将移动1像素顶部)


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. 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)

这篇关于UINavigationBar有形状的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆