I've had a good look around and I can't seem to find a good answer for this coding quandary!
I'm laying out pages in an eBook style app for iOS (Swift 3), and I'm trying to pre-calculate how many pages each chapter will need. The two main problems I'm having to tackle are:
- The page can be viewed in a two / three column layout
- The user can adjust the font size (resulting in more/less pages per chapter)
The tutorials and guides I've reviewed to achieve multi-page columnar layouts seem to require you to actually perform the laying-out of text in the UITextView before you can calculate how much text was used.
My ideal scenario would be a means to say 'I have a font of X size and this CGRect... how much text will fit inside this frame?', but without requiring me to perform the actual rendering of said text into the frame before the calculation is made (as you would using something like UITextView's characterRange(at:...)).
Is there any way to accomplish this? Am I chasing a solution for an unsolvable problem?
Thanks for any assistance that can be offered :o)