Change font size for UIAlertView in iOS7

。_饼干妹妹 提交于 2019-11-30 20:59:03

问题


I want to change the font size of message text and title text in alertView. There is no documentation in apple site that speaks about this but apple says "The UIAlertView class is intended to be used as-is" in their subclassing notes. Please refer the below link. https://developer.apple.com/library/ios/documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html

I am really confused if changing an alert view text size is something to be avoided or can it be changed? Can anyone advise me on What is the best practice for this?

If the text size can be changed, can you also provide some way of doing this?


回答1:


Yes that's correct "The UIAlertView class is intended to be used as-is". You should not access any labels in UIAlertView directly as well as you should not subclass UIAlertView - this is clearly stated by Apple and is likely to lead to a rejection of your App during revision when sent for publication to the Apple Store. The same applies to UIActionSheet.

This explains why you are not given the possibility to access any UILabel via the public API of UIAlertView. Technically you can still access them looking at the content of your UIAlertView subviews NSArray property - that in fact contains all the subviews which include UILabel and UIButton instances. However as mentioned you should absolutely avoid doing this and instead look into implementing your own alert view to be loaded modally when needed.




回答2:


Like the previous answer states you may be able to access and modify the internal labels but you absolutely 100% should not.

Not sure you will be able to customize this to your needs but you could try looking into this great loading overlay class, MBProgressHUD. But you will probably have better luck with this library (which I've havn't tried) AHAlertView.

A great source to look for iOS libraries is CocoaPods Spec Repo




回答3:


I won't say you can't, but you shouldn't.

If you really want to do this, I recommend you download this. Then look for the UIAlertView modifications and copy-paste what you need!

I really like the example project in it. Works like a quick reference to what you can do to native ios views.

Hope it helped!



来源:https://stackoverflow.com/questions/21635414/change-font-size-for-uialertview-in-ios7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!