Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apple Watch set background image

How can I programmatically set my WatchKit App background image? I need to set this in code as it changes depending on variable size and we need to place a label over the image.

like image 504
user4178770 Avatar asked Dec 20 '14 19:12

user4178770


People also ask

Can you set a picture as background on Apple Watch?

Create a photo watch faceYou can also create a Kaleidoscope watch face based on the photo, or add a new Photos watch face in the Apple Watch app on your iPhone. See Customize the watch face. , swipe up, tap Create Watch Face, then choose to create a Portraits, Photos, or Kaleidoscope watch face.

How do you set a picture as your watch background?

To begin, open the Photos app on your iPhone and select the "Recents" albums. Tap on the photo you want as your Apple Watch wallpaper, and then tap on the heart icon at the bottom to flag it as a "Favorite." By default, your Apple Watch syncs photos from your Favorites.


1 Answers

It is not possible to programatically set the background image on an entire Watch App page in WatchKit... a background image for the whole page can at the current time only be set in Interface Builder it appears.

However, you can set a picture as a background behind a label, and make that image fill the screen: Set a background image on a Group in WatchKit

  1. Create a group in your WatchKit scene. You are likely to want to set custom size attributes for the view (e.g., under Size setting Width and Height as 'Relative to Container' with a value '1' to fill the scene.
  2. Set your desired background image as the Background attribute for the group.
  3. Place your label inside the group, and format it as desired.

This group image can also be set programmatically:

  1. Set an IBOutlet for the group to your WatchKit Extension in the usual fashion, by Ctrl-dragging from the group to your Interface Controller class in the Extension.
  2. Ensure your image is included as a 'Copy Bundle Resource' in your WatchKit App (not the Extension).
  3. Set the background image in the awakeWithContext method of the Extension (assuming you called your IBOutlet 'group'):

    [self.group setBackgroundImage:[UIImage imageNamed:@"myImageName.png"]];
    

    The two techniques are of course not mutually independent. You can set an initial image in Interface Builder, and then replace it programatically later if that is called for.

like image 95
Duncan Babbage Avatar answered Oct 11 '22 23:10

Duncan Babbage