Search code examples
iosswiftuiimageviewuiimageuipageviewcontroller

UIPageViewController Affecting UIImage color?


What I'm Doing: I am creating a custom view controller for encouraging users to invite friends to the app in exchange for premium features. I am doing this via presenting a UIViewController that has a container view with a UIPageViewController embedded within the container view. The details of all of the premium features are displayed in the embedded UIPageViewController's view controllers. I have an image of some bubbles that match our brand colors that are on the leading or trailing edge of each of the UIPageViewController's view controllers such that the images "connect" into one image when panning between each view controller. This is what it looks like:

enter image description here

My problem: The problem with this approach is that, when half way panned between two of the UIPageViewController's view controllers, the colors of the bubbles in between the respective view controllers do not match:

Notice that the shades of blue where the images meet up between each respective view controller are not the same shade.

This is despite using the same "bubbles" image for each view controller, which looks like this:

UPDATE I've decided to go ahead and create a cocoapod that does the same thing presented in the question above. Feel free to check it out!

enter image description here


Solution

  • Since you only have a few pages to show, abandon UIPageViewController and configure the entire sliding interface as the content of one big continuous paged UIScrollView instead. As a bonus you won’t have to work out the splitting of the bubble image.