如何在IOS 5中调整UIBarButtonItem的图像

时间:2012-01-30 12:08:12

标签: iphone ios5

我在为UIBarButtonItem放置图像时遇到问题。这是我的代码:

UIBarButtonItem *comoseButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"compose_new.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(composeNewMessage)];

但我没有得到正确的输出:按钮尺寸太大。我该如何调整框架? (我正在为iOS 5开发)

1 个答案:

答案 0 :(得分:1)

我总是将我的条形按钮项目设计为正确的尺寸。这似乎是最简单的方法。我不知道你是否查了一下,但根据Human Interface Guidelines,它们应该是“大约20x20”。

除此之外,我想你可以用你的图片创建一个适当大小的UIImageView,添加你自己的响应者代码或手势识别器,然后使用initWithCustomView: