简体   繁体   中英

Add custom space to UILabel

I've a weird problem that faces me. I've a UILabel contains text of multiple lines and I'm using bullet in the first line "•". But my problem is that the second line is not aligned with first character after the bullet. I measured it and found that width of the bullet is a little bit bigger tan width of normal space. Is there any trick for that?

the issue is concerning font attributes. Get into the difference of monospaced fonts and proportional fonts, then you will know why there's a difference between space and bullet in your font

https://en.wikipedia.org/wiki/Monospaced_font

easy solution and maybe really an option for you is to use a monospaced font.

Okay, I found a powerful answer by using NSParagraphStyle. https://wingoodharry.wordpress.com/2016/04/10/bullet-point-list-ios-swift/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM