How to align text drawn by SpriteBatch.DrawString?
问题 Is there an easy way to align text to the right and center (instead of default left)? 回答1: The first step is to measure the string using SpriteFont.MeasureString(). Then, for example if you want to draw it to the left of a certain point, instead of to the right as is the default, then you need to subtract the X width of the measurement from the text drawing origin. If you want it to be centered, then you can use half the measurement, etc. 回答2: I use this code: [Flags] public enum Alignment {