简体   繁体   English

自定义警报视图

[英]custom alert view

Foursquare uses a customised alert (like the attached image). Foursquare使用自定义警报(如附件图像)。 I'm trying to get the same look and feel, rounded corners, fade in and fade out effect, etc. I'm looking around but all the solutions I found seems to over complicate something simple, like: 我正在尝试获得相同的外观和感觉,圆角,淡入和淡出效果等。我环顾四周,但是我发现的所有解决方案似乎都使​​一些简单的事情变得复杂了,例如:

http://joris.kluivers.nl/blog/2009/04/23/subclass-uialertview-to-create-a-custom-alert/ http://joris.kluivers.nl/blog/2009/04/23/subclass-uialertview-to-create-a-custom-alert/

Am I in the right path? 我在正确的道路上吗? Should I use some custom view class that I don't know about? 我应该使用一些我不知道的自定义视图类吗? Should I write my own? 我应该自己写吗?

图片

If the subclass that's already written works, why not? 如果已经编写的子类起作用了,为什么不呢? If not, it seems like all they're doing in that blog post you pasted in your post is override the drawRect method to draw their own graphics. 如果不是,似乎他们在您粘贴在帖子中的该博客帖子中所做的所有操作都覆盖了drawRect方法以绘制自己的图形。 If you're comfortable doing that on your own, it's a possibility. 如果您自己愿意这样做,则有可能。

The approach you linked is fine. 您链接的方法很好。 They probably subclassed UIAlertView to get the same "dim" effect when the alert pops up (see their screenshots). 他们可能将UIAlertView子类化,以在弹出警报时获得相同的“暗淡”效果(请参阅其屏幕截图)。 Foursquare doesn't have that dim effect (in your image). Foursquare没有那种暗淡的效果(在您的图像中)。 They probably simply subclassed UIView and added it as a subview to the UIWindow of the app. 他们可能只是将UIView子类化,并将其作为子视图添加到应用程序的UIWindow中。

Have a look at MBProgressHUD: https://github.com/jdg/MBProgressHUD 看看MBProgressHUD: https//github.com/jdg/MBProgressHUD

This HUD can be customised with images: 此HUD可以使用图像进行自定义:

    HUD.customView = customImage; // UIImageView
    HUD.mode = MBProgressHUDModeCustomView;

Regards. 问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM