
MountedVolumesDataSource.swift and MountedVolumesDelegate.swift: Implement the required methods to show disk information in the outline view.CGFloat+Radians.swift: Extension that converts between degrees and radians via some helper functions.NSColor+DiskInfo.swift and NSFont+DiskInfo.swift: Extensions that define constants with the default colors and fonts.VolumeInfo.swift: Contains the implementation of the VolumeInfo class, which reads the information from the hard drive, and the FilesDistribution struct that handles the split between file types.ViewController.swift: The main view controller of the application.The app lists all your hard drives, and when you click on one it shows detailed information.īefore going any further, have a look at the structure of the project to become familiar with the lay of the land: Getting Startedįirst, download the starter project for DiskInfo here. So put on your painter’s hat and get ready to learn how to color your world. In the first part of this Core Graphics on macOS tutorial, you’ll implement the bar chart using Core Graphics, before moving on to learn how to draw the pie chart using Cocoa Drawing. Use Cocoa Drawing, a tool available to AppKit apps, which defines higher level classes and functions.Paint with code by working with paths, fills, clipping areas and strings.Implement live rendering so that you don’t have to build and run every time you change your graphics.Create and configure a custom view, the base layer for any graphical element.It’s a solid example of how you can use Core Graphics to make a dull, text-based interface beautiful: In this Core Graphics on macOS tutorial, you’ll build up an app named DiskInfo to create a custom view that displays the available space and file distribution of a hard drive. It has capacity to draw anything you can imagine, from simple shapes and text to more complex visual effects that include shadows and gradients. The best of them make a lasting impression, and you always remember them because they are just so pretty.Ĭore Graphics is Apple’s 2D drawing engine, and is one of the coolest frameworks in macOS and iOS. You’ve seen a lot of apps that depict beautiful graphics and stylish custom views.


Update 9/22/16: This tutorial has been updated for Xcode 8 and Swift 3.
