0

So I'm working on a custom music player app. I need to be able to dynamically change the color of the Navigation bar based on the content displayed in the view. I've searched around and can't seem to find a way to do it if it's even possible. I know how to change the color to basically any color but not have it change based on the colors of a UIImage. This is what my designer has come up with.enter image description here

I also need to change the colors of the buttons within that same table view cell and on the Navigation bar basically the same way. Here is what I have in storyboard already.enter image description here

I also need to be able to change the colors of the tab bar and it's items. I don't know if this is even possible. Could someone shed some light on this or maybe point me in the right direction

  • For navigation bar color, get the color of the top most pixels in the image view and set it as background color and for tab bar do the same thing(take the nearest image pixel color and set it). You can also make the color more smoother(similiar to image) by aggregating rgb values and deriving new color from the aggregated rgb value. I don't have much idea other then this. Use this link for getting pixel colour of an image :https://stackoverflow.com/questions/21028952/how-to-get-the-pixel-color-values-of-custom-image-inside-imageview-ios – jegadeesh Jun 05 '17 at 06:19
  • So could I say declare a CGPoint on the image and get the pixel color of that point and then set the color to the color at the CGPoint and then when the image changes the colors change? – CarpenterBlood Jun 05 '17 at 06:25
  • yes, just give it a try. (While considering other answers) – jegadeesh Jun 05 '17 at 06:39
  • Hey thanks for your responses It worked like a charm, had to ditch the tabBarController cause it was returning nil but i will use a toolbar with containerViews and it should all seem the same – CarpenterBlood Jun 05 '17 at 09:11
  • Welcome man. :) – jegadeesh Jun 05 '17 at 09:19

1 Answers1

0

The simplest way to achieve this design will be to make the navigation bar completely transparent and give the full screen image top constraints as 0 with the view. Then the image will be shown from top of the screen. Then give the navigation bar a shadow image as per the design. But for the tab bar I believe you might have to pick the color from imageview and change the tab bar's background.

Aravind A R
  • 2,674
  • 1
  • 15
  • 25
  • The problem with this is it is a tableView and when the user scrolls up the colors will change and that isn't the desired design. I've already looked into that. – CarpenterBlood Jun 05 '17 at 06:39
  • Ok then you might have to have to pick the color from imageview and change the background color accordingly. But I believe you might have to pick the color from a background thread and update color from main thread – Aravind A R Jun 05 '17 at 07:12