开发者

iphone - custom font costs extra memory?

I need to use an external custom font for my UILabel. I managed to do it and it is working.

I have totally like 50 UILabel in my app. Each UILabel has the same custom font that I embed with my app.

All 50 UILabels are loaded at one time into the memory.

Each UILabel's text is around 200 bytes of NSStrings, the sum of all texts are around 1K - 2K bytes. I made a mistake previously by writing each UILabel's text is 1K - 2K, sorry.

I noticed one thing, if I apply the custom font to the UILabels, the memory costs ver开发者_运维百科y high, like 30 - 40MB extra more than without custom fonts.

Is this possible?

My app is very simple currently just show 5 pages, each page has 10 UILabels. So no other places or bugs would exist, I think


If the labels have 1k - 2k worth of text I am sure that 50 of them can not be displayed all at once. The approach to take here is similar to how the UITableView works, as the user scrolls, switch tabs, etc then only display labels that will be visible to the user and unload the others. This will reduce the memory peak and you will only need to have the custom fonts loaded for the displayed labels.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜