【发布时间】:2010-12-01 13:23:27
【问题描述】:
我在下面的工具栏中添加了一个按钮,如下所示:
UIImage *locationImage = [UIImage imageNamed:@"193-location-arrow.png"];
UIBarButtonItem *locationButton = [[UIBarButtonItem alloc] initWithImage:locationImage style:UIBarButtonItemStyleBordered target:self action:@selector(updateCurrentLocation)];
NSArray *items = [[NSArray alloc] initWithObjects:locationButton,nil];
[toolbar setItems:items];
[items release];
[locationButton release];
这很好用,图像的 alpha 拾取得很好,按钮显示如下:
因此,我采用了这段代码并稍作修改,在导航栏中创建了一个按钮:
UIImage *favouriteImage = [UIImage imageNamed:@"28-star.png"];
UIBarButtonItem *favouriteButton = [[UIBarButtonItem alloc] initWithImage:favouriteImage style:UIBarButtonItemStyleBordered target:self action:nil];
self.navigationItem.rightBarButtonItem = favouriteButton;
[favouriteButton release];
这个 alpha 似乎没有被选中 - 它看起来是灰色的:
在导航栏中使用自定义图像时我需要设置什么吗?
感谢和问候,
丰富
【问题讨论】:
标签: iphone image uibarbuttonitem alpha