Search code examples
iosobjective-cuistoryboardwatchkitapple-watch

Watchkit Interface Controller 38mm and 42mm background image size


For some reason, I have searched high and low, and cannot find the exact image sizes that I need to supply for a background image for both the 38mm and 42mm sizes in Watchkit. Currently I am stretching a smaller image using "scale to fill".

enter image description here

enter image description here

I don't want it stretched, so I am looking for real pixel sizes.


Solution

  • Here is the code I use to get the size for the background image in my WKInterfaceController. My app has a page control, you you probably don't want the extra -14 at the end.

    -(CGSize)backgroundSize
    {
        CGRect contentFrame = self.contentFrame;
        CGSize size = contentFrame.size;
        CGFloat contentScale = 2.0;
        size.width *= contentScale;
        size.height *= contentScale;
    
        //I lined up the generated image with one in the simulator until
        //they perfectly matched.  I did this on both 38 and 42 mm.
        //I am not sure why they all came out to be off 4.
    
        //There is an offset of 10 in IB and I am not sure I need this
        //to be 4 to match perfect.
        size.height -= 4;
    
        //it looks like there is 2 pixels around the edge
        size.width -= 4;
    
        //Using page mode we need to take off an additional 14 pixels for the page dots at the bottom
        size.height -= 14;
    
        return size;
    }