Skip to content

Images and Icons Legacy

Simone Martorelli edited this page Mar 15, 2021 · 1 revision

Image, color, and texture sets are located in Assets.xcassets in the project directory. Images can also be created through swift code and applied to interface objects.

Left Panel

Dark Mode adoption requires both a light and dark variant of the image and the transition is automatically handled provided that the image is stored in an image set (using the provided left-panel image set will adjust the project without the need to re-map in interface builder). Each variation has two sizes (1x and 2x) using the following pixel dimensions:

 1x : 320 x 520

 2x : 640 x 1040

Application Icon

The application icon uses the standard AppIcon image set. Each resolution has two variations (1x and 2x) using the following pixel dimensions:

 16x16.png : 16 x 16
 
 16x16@2x.png : 32 x 32
 
 32x32.png : 32 x 32

 32x32@2x.png : 64 x 64

 128x128.png : 128 x 128

 128x128@2x.png : 256 x 256

 256x256.png : 256 x 256

 256x256@2x.png : 512 x 512
 
 512x512.png : 512 x 512

 512x512@2x.png : 1024 x 1024

Icons (for Apps used in Bundle Info Popovers or Education Links)

For this example, we are looking at app icons used for the bundle info popovers. If the image set is configured for Universal, there will be three variations. If configured for Mac, there will be two. These image sets were brought over from an earlier build of the application set to Universal with the following pixel dimensions:

 icon.png : 33 x 34

 icon@2x.png : 66 x 68

 icon@3x.png : 99 x 102

These images can be accessed by their image set name ie. NSImage(named: "notes-icon"). For more examples of this behavior, see AppBundlesConstants.swift for the arrays containing icons for each bundle.

Swift created images

Some images and shapes are created directly with swift code. The below example is taken from InfoBubble.swift with the code folded for space:

1) the drawing method for the shape containing the basic size, color assignments, and paths
2) the class you would call in order to assign the image to an object
3) a resizing enumerator to allow for scaling up or down 

An example of assigning this shape to a button:

  1. Create a button of particular size. The dimensions used for the info button are 15 x 15.

  2. Create a reference outlet for the button in the controller. An example would be: @IBOutlet weak var nameErrorInfoBubble: NSButton!

  3. Assign the image to the button: nameErrorInfoBubble.image = InfoBubble.imageOfInfo_bubble

    An example of this can be found in both interface builder and code related to the PrimaryRegistrationChildViewController.swift class.

Clone this wiki locally