2

Is it possible to invert the color of a UIView or UIScrollView and all its subviews in iOS?

If so how can I accomplish this?

1

1 Answer 1

-1

First, you need to create an inverted color of current background color of UIView. You can learn more about how to accomplish it on this StackOverflow question — How to get inverse color from UIColor?

Then, you need to iterate over all UIView subviews and apply inverted color as a background.

view.backgroundColor = invertedColor;
for (UIView *subview in view.subviews) {
    subview.backgroundColor = invertedColor;
}
1
  • What if the UIView contains a PDF? and not just a background color?
    – user906357
    Commented Jul 19, 2014 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.