Sample CodeiOS, iPadOS, Mac CatalystReviewed 2026-07-21View on Apple Developer

Creating a Sticker App with a Custom Layout

At a glance

Item Summary
Purpose Expand on the Messages sticker app template to create an app with a customized user interface.
App architecture A Swift sample centered on MessagesViewController, with direct use of UIKit, Messages.
Main patterns View-controller organization, Delegate or data-source callbacks
Project style 3 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries.

Project structure

Source bundle/
├── Stickers/
│   ├── Stickers MessagesExtension/
│   │   ├── StickerCollectionReusableViews.swift
│   │   ├── MessagesViewController.swift
│   │   ├── Stickers+Extensions.swift
│   │   ├── Base.lproj/
│   │   │   └── MainInterface.storyboard
│   │   └── Info.plist
│   ├── Stickers.xcodeproj/
│   │   ├── .xcodesamplecode.plist
│   │   └── project.pbxproj
│   └── Stickers/
│       └── Info.plist
└── Configuration/
    └── SampleCode.xcconfig

Structure observations

  • Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
  • Primary languages: Swift.
  • The verified tree contains 6 project/configuration file(s) and 8 source declaration(s).

Overall architecture

Reference code

Stickers/Stickers MessagesExtension/MessagesViewController.swift:11 — architecture anchor

class MessagesViewController: MSMessagesAppViewController {
    // ...
}

Interpretation

The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into Messages.

Ownership and state

Ownership evidence

Stickers/Stickers MessagesExtension/StickerCollectionReusableViews.swift:11 — stored dependency or nearest verified ownership anchor

    let label = UILabel()
    static let reuseIdentifier = "title-supplementary-reuse-identifier"

    override init(frame: CGRect) {
        super.init(frame: frame)
        configure()
    }
Owner Object or state Relationship Mutation authority
TitleSupplementaryView UILabel (label) creates and retains Initialized by the owner; the binding is immutable
TextSupplementaryView CustomField (field) creates and retains Initialized by the owner; the binding is immutable
PictureSupplementaryView UIButton (button) creates and retains Initialized by the owner; the binding is immutable
CustomContentConfiguration MSSticker (sticker) stores or receives App/module collaborators

Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.

Class and protocol design

Stickers/Stickers MessagesExtension/StickerCollectionReusableViews.swift:10 — representative type boundary

class TitleSupplementaryView: UICollectionReusableView {
    // ...
}
Type Responsibility Depends on or conforms to
TitleSupplementaryView User-interface presentation and input forwarding UICollectionReusableView
TextSupplementaryView User-interface presentation and input forwarding UICollectionReusableView
PictureSupplementaryView User-interface presentation and input forwarding UICollectionReusableView
CustomContentView User-interface presentation and input forwarding UIView, UIContentView
MessagesViewController View lifecycle, callbacks, and feature coordination MSMessagesAppViewController
CustomField Owns feature behavior and collaborator lifecycle UITextField
CustomContentConfiguration Carries feature or framework configuration UIContentConfiguration, Hashable
SectionType Defines a closed set of feature states or choices String, CaseIterable

No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.

Access control

Symbol Access Verified effect Likely rationale
collectionView (Stickers/Stickers MessagesExtension/MessagesViewController.swift:21) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
datasource (Stickers/Stickers MessagesExtension/MessagesViewController.swift:22) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
fiveItemSection (Stickers/Stickers MessagesExtension/MessagesViewController.swift:24) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
oneItemSection (Stickers/Stickers MessagesExtension/MessagesViewController.swift:34) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.

Reference code

Stickers/Stickers MessagesExtension/MessagesViewController.swift:21 — representative boundary

class MessagesViewController: MSMessagesAppViewController {
    // ...
    private var collectionView: UICollectionView!
    // ...
}

Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.

Logic ownership and placement

Logic Owning type or file Placement rationale
View lifecycle, callbacks, and feature coordination MessagesViewController The source’s Controller suffix makes this role explicit.
User-interface presentation and input forwarding CustomContentView, PictureSupplementaryView, TextSupplementaryView, TitleSupplementaryView The source’s View suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
View-controller organization Stickers/Stickers MessagesExtension/MessagesViewController.swift:11 A controller is the verified coordination boundary; this is MVC-style only where a separate model is present.
Delegate or data-source callbacks Stickers/Stickers MessagesExtension/MessagesViewController.swift:210 Callback protocols invert event delivery back into the sample’s owner.

Naming conventions

  • Types: Controller: MessagesViewController; View: CustomContentView, PictureSupplementaryView, TextSupplementaryView, TitleSupplementaryView.
  • Protocols: no local protocol declaration in the scanned source.
  • Methods: configure, textRect, editingRect, makeContentView, updated, setupInternalViews, apply, createLayout.
  • Files: Stickers/Stickers MessagesExtension/MessagesViewController.swift.

Architecture takeaways

  • MessagesViewController is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches UIKit, Messages through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
  • Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
  • Access-control conclusions separate verified language visibility from the likely design rationale.
  • The source does not justify labeling the design protocol-oriented.

Source map

Source file Relevant symbols
Stickers/Stickers MessagesExtension/StickerCollectionReusableViews.swift TitleSupplementaryView, TextSupplementaryView, CustomField, PictureSupplementaryView, CustomContentConfiguration, CustomContentView
Stickers/Stickers MessagesExtension/MessagesViewController.swift MessagesViewController, SectionType
Stickers/Stickers MessagesExtension/Stickers+Extensions.swift Feature implementation