2

I have an app that I want to debug. I'd like every UITextview within the app to have a purple background.

I think method swizzling is a possible solution, but I have not been able to get this to work.

Question: How can I do this without subclassing or manually setting each textview's background color?

Thank you

1 Answers1

2

Something like this should do the trick:

[[UITextView appearance] setBackgroundColor:[UIColor purpleColor]];

The appearance proxy was introduced in iOS5 as a convenient way for styling core UIKit classes without subclassing. It can be used in a variety of really useful ways such as setting a UINavigationBar's tint color, button tints, etc.

Andrew
  • 1,279
  • 2
  • 13
  • 19
  • 2
    Thanks that was really helpful. I never knew about:[UITextView appearance]. It doesnt seem to work with Textview's though :( http://stackoverflow.com/questions/9424112/what-properties-can-i-set-via-an-uiappearance-proxy – user3666483 May 22 '14 at 20:00
  • Have you tried it on iOS 7.1? I just gave it a shot and it worked as expected, all my text views were infact purple. Let me know if it's not working on other versions. – Andrew May 22 '14 at 21:30