带有自定义按钮的自定义 UIAlertView
我需要显示一个自定义 UIAlertView,它将有一个图像作为背景和两个自定义按钮,这将不是常规的 UIAlertView 按钮。这些按钮也将被定制,并有自己的艺术品。
上面的示例有一个背景,但我还想在其上添加自定义按钮。
我正在遵循此指南,但我认为它没有解决自定义问题按钮处理。
怎么做呢?有什么想法吗?
I need to show a Custom UIAlertView which is going to have an image as a background and two Custom Buttons which will be not the regular UIAlertView Buttons. These buttons will be customized as well and would have their own Artwork.
The example above has a background but I also want to add Custom Button on it.
I am following this guide but I don't think it address the Custom Button handling.
How to do that? Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
苹果似乎不喜欢你过度定制 UIAlertView,我听说过很多次他们因此拒绝了应用程序进入应用程序商店。
由于您所追求的自定义程度,我建议您创建自己的新警报类,该类具有动画效果并具有背景阴影等,并带有可以自定义其位置/外观的按钮。
Apple doesn't appear to like you overly-customising UIAlertView, and I've heard of a number of occasions where they've declined an app going into the app store because of it.
Because of the extent of customisation you're after, I suggest you create your own new Alert class that animates in and has a background shadow etc with buttons that you can customise the location/look of.
我发现 Jeff LaMarche 的这篇博客文章对于制作自定义警报视图非常有帮助:http://iphonedevelopment.blogspot.com/2010/05/custom-alert-views.html。他完成了创建自定义类的步骤,因为修改 UIAlertView 可能会导致 App Store 拒绝(但是他警告说,使用自定义技术仍然会导致 HIG 违规,但我怀疑它们会导致您想要做的事情)。完成后,您将拥有一个自定义警报视图类,可以以与 UIAlertView 大致相同的样式添加它:
他创建一个自定义文本输入视图。显然,在您的情况下,您可能希望使用不同的背景,而不是添加文本字段,而是只使用按钮。由于他也在他的视图中制作了自定义按钮,因此它应该可以满足您的所有需求,甚至更多。
I found this blog post by Jeff LaMarche to be really helpful in making custom alert views: http://iphonedevelopment.blogspot.com/2010/05/custom-alert-views.html. He goes through the steps of making a custom class since modifying UIAlertView can cause App Store rejection (however he warns that using custom techniques can still cause HIG violations, but I doubt they will for what you're trying to do). By the time you're done, you'll have a custom alert view class that can be added in much the same style as UIAlertView:
He creates a custom text input view. Obviously, in your case, you would want to use a different background and instead of adding a text field you'd stick to just the buttons. Since he makes custom buttons in his view too it should cover all your needs, if not more.
不幸的是苹果不允许子类化 UIAlertView:
最简单的方法是创建您自己的具有类似行为的类。
这是一个例子:
http://iosdevtricks.blogspot.com/2013 /04/creating-custom-alert-view-for-iphone.html
Unfortunately Apple does not allow subclassing UIAlertView:
The easiest way would be to create your own class with similar behavior.
Here's an example:
http://iosdevtricks.blogspot.com/2013/04/creating-custom-alert-view-for-iphone.html