Introduction
As there was no text box in the XNA environment I was forced to create a text box by myself, and wanted to share the solution here for programmers.
Using the Code
First think that we need to draw our text, so what do we need to wrap text in a rectangle? Below is my source code to wrap text in a rectangle by width. So the spirtfont
is for measurement purposes, text is what you want to wrap in the textbox, and maxLineWidth
is the parameter for the width of the TextBox
.
参考: