Change font size for UIAlertView in iOS7

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?

Answers


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.


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


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!


Need Your Help

.load to call 'facebook like box' is breaking jquery

jquery html css facebook

I am seeing some strange behavior when trying to call "facebook like box" with Ajax.

AVAudioPlayer Error Domain=NSOSStatusErrorDomain Code=-43

ios ios5 avaudioplayer mpmediapickercontroller

I get the error above when trying to play a song file (chosen via MPMediaPickerController). Works fine in iOS6, but on iOS5 I get the error. Here's the code: