我正在使用自定义字体,我有一点障碍. 
  
 
有些字体可以正常使用sizetoFit,如下所示:
但是,其他自定义字体在左侧和底部被截断,因为这是:
我可以“破解”它,只检查每种字体类型并添加几个像素,但我想知道是否有更清晰的解决方案,甚至解释为什么会发生这种情况.
谢谢!
这是我的自定义UILabel字体设置代码
func setNewFont(fontName:String,size:CGFloat)
    {
        self.font = UIFont(name: fontName,size: size)
        sizetoFit()
    }
解决方法
 这篇文章解释了如何解决垂直问题: 
  
 
        http://www.andyyardley.com/2012/04/24/custom-ios-fonts-and-how-to-fix-the-vertical-position-problem/
然而,字体的左侧仍然被切断.
所以除了上面的修复,我还覆盖了绘制调用并偏移了x值
(调整xml文件中的minLeftbearing没有修复任何东西,显然xcode忽略它).
override func drawTextInRect(rect: CGRect)
    {
        if(font.fontName == "JennaSue")//JennaSue
        {
            var newBounds:CGRect = CGRectMake(rect.origin.x+2,rect.origin.y,rect.width,rect.height)
            super.drawTextInRect(newBounds)
        }else
        {
            super.drawTextInRect(rect)
        }
    }