-
Notifications
You must be signed in to change notification settings - Fork 48
Images and Icons Legacy
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.
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
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
[email protected] : 32 x 32
32x32.png : 32 x 32
[email protected] : 64 x 64
128x128.png : 128 x 128
[email protected] : 256 x 256
256x256.png : 256 x 256
[email protected] : 512 x 512
512x512.png : 512 x 512
[email protected] : 1024 x 1024
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
[email protected] : 66 x 68
[email protected] : 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.
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:
-
Create a button of particular size. The dimensions used for the info button are 15 x 15.
-
Create a reference outlet for the button in the controller. An example would be:
@IBOutlet weak var nameErrorInfoBubble: NSButton!
-
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.