为导航栏创建按钮
我的导航栏上有一个按钮作为右侧按钮:
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonItemStyleBordered target:self action:@selector(addToFavouritesButtonPressed:)];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];
一切都很好,只是我希望它是一个带有一点加号的星星图像。认为创建一个 png 并设置 UIBarButtonItem 的图像属性会很容易。但事实确实如此,有两件事。它将光泽度和斜角放在图像的左侧和右侧,但不在图像本身上,其次我在文档中找不到推荐的按钮尺寸。
是否有一种简单的方法来创建按钮图像和系统对其进行格式化,使其看起来像是导航栏的一部分?如果我尝试在 Photoshop 中创建光泽和斜角,它看起来不错,但看起来不太像左侧系统生成的按钮。
希望这是有道理的,任何指示都会受到赞赏,
戴夫
I have a button as the right button on my navigation bar:
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonItemStyleBordered target:self action:@selector(addToFavouritesButtonPressed:)];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];
All good, except I'd like it to be an image of a star with a little plus on it. Thought it would be easy to just create a png and set the UIBarButtonItem's image property. Which it is, however 2 things. It puts the gloss and bevel at the left and right side of my image, but not on the image itself and secondly I can't find a recommended size of button in the docs.
Is there an easy way of creating a button image and the system to format it so it looks like it is part of the Navigation Bar? If I attempt to create the gloss and bevel in Photoshop it looks good but doesn't look quite like the system generated buttons on the left side.
Hope that makes sense and any pointers would be appreciated,
Dave
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哦,我的 png 中没有 Alpha 通道,创建了一个蒙版,一切看起来都不错。
Doh, didn't have an alpha channel in my png, created a mask and all looks good.