简体   繁体   中英

Custom Font Issue in iOS

In my app, I used custom fonts. It works fine for UILabel s, etc...

But the Title is cut from top for Button.

在此处输入图片说明

"See the S"

What is happening and how can I resolve this??

尝试设置button.contentEdgeInsets属性以使按钮内的标题对齐,如果这是字体基线错误的问题,则可以执行此操作

button.titleLabel.baselineAdjustment =  UIBaselineAdjustmentAlignCenters

a few steps:

  1. Include your fonts in your XCode project
  2. Make sure that they're included in the target
  3. Double check that your fonts are included as Resources in your bundle
  4. Include your iOS custom fonts in your application plist
  5. Find the name of the font
  6. Use UIFont and specify the name of the font

detail for this: http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/

thanks!

In my case it was the font file that was corrupted. Try to open the ttf file in your mac, select the 'S' and see if the frame that appears cuts off the letter. My solution was to change the ttf file.

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