Now available on Microsoft Store — Windows 10 / 11, Chinese and English UI. Get it now →
Home / Blog / Sprites & UI

Sprite sheets and nine-patch: slicing mobile UI the right way

Sprite splitting, nine-patch stretch regions, batch borders and rounded corners, and verifying shapes in the engine afterwards.

Key takeaways

  • Four guide lines define a nine-patch
  • Corners and strokes belong in non-stretch regions
  • Verify slices at real resolutions

Mobile UI leans on stretchable panels: buttons, dialogs, bubbles, list rows. They are all rounded rectangles in wildly different sizes. Slicing one image per size makes the package balloon.

How nine-patch works

A nine-patch divides an image with two horizontal and two vertical guide lines into nine regions. Corners stay fixed, edges stretch in one direction, the center stretches in both. One small image then fits any size while keeping corners and strokes intact.

The guides must sit in areas that are safe to stretch. Rounded corners, strokes and decorations belong in the fixed parts of corners or edges, or they smear when stretched.

Sprite splitting

The reverse need is just as common: take a packed sheet and split it into individual images, or repack under new rules. Splitting involves irregular gaps, transparent margins and naming — slow and error-prone by hand.

TexForge's atlas toolbox splits by alpha bounds, writes individual images and preserves naming, which makes reprocessing or migrating to a new atlas straightforward.

Batch corners and strokes

UI assets usually follow a spec: corner radius, stroke width, padding, shadow. Encoding these as batch actions is far more controllable than letting every artist improvise. Change the spec once, regenerate everything.

  • Drive radius and stroke width with parameters instead of pixel-level manual edits.
  • Keep transparent padding so nine-patch guides have room.
  • Export @1x / @2x / @3x with consistent naming.

Verify after export

The usual nine-patch failure is not slicing — it is stretching badly in the engine. Check each asset at real resolutions and extreme aspect ratios: very long buttons, very narrow rows, very large bubbles.

A nine-patch is only done when it looks right at both 320 and 1440 pixels wide.

Takeaway

Sprite sheets solve quantity; nine-patch solves variation. The first needs packing and splitting tools, the second needs guide discipline and verification. Both are rule problems, which is why both suit batch processing.

Available on Microsoft Store

Install directly on Windows 10 / 11 (x64). Chinese and English UI included.

Get it fromMicrosoft Store