Entering Pinyin tone marks in Mac OS X is a little challenging. There are some ways to do so, most notably using the built-in “ABC Extended” keyboard layout, but the key combinations are not very intuitive. Hence I created my own layout that uses simple CTRL key shortcuts for entering the tones, for example:
To use the Pinyin keyboard layout, first download gb-pinyin-20190530.zip. Unzip it and double-click the unzipped file to install it. Finally, go to System Preferences / Keyboard / Input Sources and add it to the list of active input sources.