Search code examples
iosuibuttonuiimageinsets

iOS. How to draw complex images on a UIButton?


I need to make something like this (rectangles mean various pictures):

enter image description here

I know that it is possible to do this by making one image from two and assigning it to a UIButton. But is there another way to do it by using insets?


Solution

  • If you want the "button pressed" highlighted state for both images you could

    • Make it one image and one button
    • Make two buttons and assign images and implement a method (add to both buttons as target for UIControlEventAllEvents) that sets button1.highlighted & button2.highlighted = ((UIButton*)sender).highlighted