4 min read

How to outsmart iOS widget documentation: 4 practical tips

The iOS documentation for widgets contains not only features, but a number of limitations. For developers, it represents more of a challenge to determine how they can be circumvented. Frequent updates, animations, transparency, and interactivity — iOS Developer Nadzeya Savitskaya compares documentation with reality and shares professional life hacks.

iOS Developer Nadzeya Savitskaya

Other articles by the author:

— More than two years ago, Apple introduced widgets. First for the Home Screen and, more recently, for the Lock Screen.

Widgets are additions to the main application. They can be added to the Home and/or Lock Screens, so that some important information from the application will always be at hand, without the need to access the main application. It can be anything: weather, photos, the last message received, or the number of levels in the game.

If you read the documentation on widgets, at every turn you will run into limitations. The world would be boring if no one tried to get around them, and developers always try to squeeze the most out of opportunities.

Frequent updates

— The documentation says: a limited amount of memory is allocated for widgets, and it is often impossible to update them. This is the most interesting part about the limitations of widgets. Indeed, little memory is allocated to widgets. This process is completely controlled by the iOS system, and developers have very little influence on it. Frequent widget updates "clog" all of the allocated memory, and the widget at some point simply stops updating until the system decides to clear the memory for widgets. This happens about once a day, depending on the use of the widget. Simply put, the system collects data for several days on how often the user looks at a widget, and builds a memory clearing schedule accordingly.

It is necessary to distinguish between types of widget updates:

  1. The first type of update is when we know in advance what information we need to update the widget. This includes widgets with a clock, calendar, countdown, photo widgets, etc.
  2. The second type is when we do not know. This type includes weather widgets, news widgets, widgets for mail applications, etc. If you want more detail about the difference, read about the work of Timeline Provider.

To identify the frequency of updates that will enable the widget to work for a day, I tried many combinations of updates. For updates of the first type, the working minimum is updating 1 time per minute. For updates of the second type, it is updating 1 time every five minutes. No matter how hard we try to update widgets instantly, we cannot guarantee stable operation. But even the update frequency I identified allows you to close a lot of real tasks.


— The documentation says: widgets are static, no animations are supported. After reading this phrase, I immediately wanted to check: if I add to the widget .png images for the background .gif file, then what will happen? The answer is simple: the result will just be a completely black widget without any hint of animation, or the display of even the static first frame of the animation.

I have good and bad news regarding animated widgets. They can be made, but they will not work for long. To simulate a gif on a widget, we have to go through several tricks:

  1. We will alternately show pictures, animation frames.
  2. We will update the images once every 1 second.
  3. We will enjoy the animation on the widget until the memory is full and the system resets it in about a day.

Yes, the solution only half works, but is still possible. Which is good news.

Transparency (Home screen)

— The documentation says: you cannot use images with transparency in widgets. Indeed, the transparency in the picture will simply be displayed in black or white, depending on the iOS theme you choose. But what stops us from trying to imitate the transparent background of the widget on the Home Screen? Of course, nothing. We just need to do the following:

  1. Request from the user the wallpaper that is currently on their Home screen.
  2. Request from the user the place where they want to put the widget, for example, the upper right corner.
  3. Ask the user what size widget they want to install: small, medium, or large.
  4. Ask the user what their phone model is. The exact size of the widget depends on this.
  5. Cut out the desired part of the user’s wallpaper and put it as a background on the widget.

When installing such a widget, if everything is calculated correctly, the borders of the widget will be completely invisible, and the transparency effect will be very real.


— The documentation says: widgets are not interactive, it is impossible to make buttons in them that will change anything on the widget itself. But that doesn't mean we can't click on widgets at all.

By default, clicking on the widget opens the main application, and the developer can track such an opening. And redefine it. For small Home Screen and all Lock Screen widgets, you can override clicking on the entire widget. In medium and large Home Screen widgets, you can add several buttons and make your own events for each of them. Examples of the kind of events that can be added include:

  1. Open the desired screen in your application.
  2. Open another application.
  3. Open a web page.
  4. Create some custom action in advance through the Shortcuts application and execute it.

— Yes, you cannot make a mini-game on a widget, but to say that a widget is just a static picture is not entirely true. I wanted to share with you my experience of circumventing some restrictions when working with widgets. I will be glad to receive feedback!

If you want to share your expert experience, become a hero of club!