Skip to content
  1. We help small teams achieve big things.
  2. Our Technical Fellow just became a Microsoft MVP!
  3. We run the Azure Weekly newsletter.
  4. We just won 2 awards.
  5. We just published Programming C# 8.0 book.
  6. We run the Power BI Weekly newsletter.
  7. Our NDC London 2020 talk is now available online!
  8. We are school STEM ambassadors.
Pascal Arnould By Pascal Arnould Software Engineer III

One way to manage a button visual state in iOS is by setting a different background image for each one of the UIControlState values available: Normal, Disabled, Highlighted and Selected. If all you want is a solid colour background for each specific state, you still have to create separate images, save them as bundle resources and refer back to them in code. This feels like a lot of effort for something which should be a bit more straight forward. However one of the answers to this question on Stack Overflow provided a better solution by creating a 1x1 pixel image programmatically based on a given color. Here's the direct port of the code in C#:

You can then use this utility method to create a button background images and set its visual states as shown below:

Pascal Arnould on Twitter

Pascal Arnould

Software Engineer III

Pascal Arnould

He has over 20 years experience of of implementing complex technology solutions across a number of sectors, and is a passionate advocate of Agile practices, continuous learning and engineering excellence.

Pascal worked at endjin from 2013 - 2015.