地图页面卷曲按钮自定义实现突出显示

发布于 2024-10-05 03:19:00 字数 421 浏览 0 评论 0原文

我一直试图让它与地图选项的地图应用程序图标相同,但没有成功。我试图在 UIToolBar 的右上角制作地图卷曲按钮。我无法让 SDK 中的按钮跟随颜色,因此我必须创建自己的外观相似的按钮。

为了将其添加到工具栏,我使用 UIControlStateNormal 的图像创建一个自定义按钮,使用 customView 创建 UIBarButtonItem 作为 pageFlip 按钮。

这工作正常,但我需要在用户触摸它时保持它突出显示(然后在用户完成后恢复正常)。当用户当前触摸它时,它确实会变成阴影,但我尝试设置 [button setSelected:YES]; 并且没有骰子。我尝试将按钮的不同状态设置为当前图像,但这也不起作用。我想我可以为要设置的按钮创建一个突出显示的图像,但这对于看起来很简单的事情来说需要很多时间。

我有什么想法可以尝试吗?

I've been trying to get this the same as the maps app icon for map options but no success. I was trying to make the map curl button in the right corner of the UIToolBar. I couldn't get the button that comes in the SDK to follow the colouring so I had to create my own similar looking button.

To add this to the tool bar I create a custom button with the image for UIControlStateNormal, Create the UIBarButtonItem with a customView as the pageFlip button.

This works fine but I need to keep it highlighted when the user touches it (and then return back to normal after the user is finished). When the user touches it currently it does become shaded but I've tried setting [button setSelected:YES]; and no dice. I've tried setting the different states of the button to the current image but this doesn't work either. I assume I could create a highlighted image for the button to set but thats a lot of time for something that really seems simple.

Any thoughts I could try?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疾风者 2024-10-12 03:19:00

要将 UIBarButtonItem 设为蓝色,它必须具有“完成”样式。您无法在运行时更改按钮的样式,因此唯一的选择就是用新按钮替换工具栏的内容。幸运的是,您可以指定它必须是动画的。

我知道你在想什么。这很糟糕。

To make a UIBarButtonItem blue, it must have the "Done" style. You cant change the style of a button at run-time so the only alternative left is to replace the contents of the toolbar with new buttons. Fortunately, you can specify that it must be animated.

I know what you're thinking. It's pretty bad.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文