iOS 大多数字体的整理与展示

字体的整理与展示

swift:

iOS 大多数字体的整理与展示_第1张图片

iOS 大多数字体的整理与展示_第2张图片


目前整理出来的字体

  • Zapfino
  • Verdana-Italic
  • Verdana
  • Verdana-BoldItalic
  • Verdana-Bold
  • TrebuchetMS-Bold
  • Trebuchet-BoldItalic
  • TrebuchetMS
  • TrebuchetMS-Italic
  • TimesNewRomanPS-ItalicMT
  • TimesNewRomanPS-BoldItalicMT
  • TimesNewRomanPS-BoldMT
  • TimesNewRomanPSMT
  • STHeitiTC-Medium
  • STHeitiTC-Light
  • STHeitiSC-Light
  • STHeitiSC-Medium
  • MarkerFelt-Thin
  • HiraKakuProN-W3
  • HelveticaNeue-Bold
  • HelveticaNeue
  • Helvetica-Bold
  • Helvetica
  • Helvetica-BoldOblique
  • Helvetica-Oblique
  • Georgia-Italic
  • Georgia-BoldItalic
  • Georgia
  • Georgia-Bold
  • DBLCDTempBlack
  • CourierNewPSMT
  • CourierNewPS-BoldItalicMT
  • CourierNewPS-ItalicMT
  • CourierNewPS-BoldMT
  • Courier-Bold
  • Courier-Oblique
  • Courier-BoldOblique
  • ArialRoundedMTBold
  • Arial-ItalicMT
  • Arial-BoldItalicMT
  • Arial-BoldMT
  • ArialMT
  • AppleGothic
  • AmericanTypewriter-Bold
  • AmericanTypewriter

“STHeitiK-Medium”, “STHeitiK-Light”, “STHeitiJ-Light, “STHeitiJ-Medium”, “Courier”, “ArialUnicodeMS”——————-这些字体是显示不出来的 如果有知道的 希望能指导一下 万分感谢!!!

码块

代码块语法遵循标准markdown代码,例如:

//循环显示所有字体
    override func touchesBegan(_ touches: Set, with event: UIEvent?) {
        //整理出来的字体数组
        let array = ["Zapfino", "Verdana-Italic", "Verdana", "Verdana-BoldItalic", "Verdana-Bold", "TrebuchetMS-Bold", "Trebuchet-BoldItalic", "TrebuchetMS", "TrebuchetMS-Italic", "TimesNewRomanPS-ItalicMT", "TimesNewRomanPS-BoldItalicMT", "TimesNewRomanPS-BoldMT", "TimesNewRomanPSMT", "STHeitiTC-Medium", "STHeitiTC-Light", "STHeitiSC-Light", "STHeitiSC-Medium", "MarkerFelt-Thin", "HiraKakuProN-W3", "HelveticaNeue-Bold", "HelveticaNeue", "Helvetica-Bold", "Helvetica", "Helvetica-BoldOblique", "Helvetica-Oblique", "Georgia-Italic", "Georgia-BoldItalic", "Georgia", "Georgia-Bold", "DBLCDTempBlack", "CourierNewPSMT", "CourierNewPS-BoldItalicMT", "CourierNewPS-ItalicMT", "CourierNewPS-BoldMT", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique", "ArialRoundedMTBold", "Arial-ItalicMT", "Arial-BoldItalicMT", "Arial-BoldMT", "ArialMT", "AppleGothic", "AmericanTypewriter-Bold", "AmericanTypewriter"]
        //STHeitiK-Medium//STHeitiK-Light//STHeitiJ-Light, "STHeitiJ-Medium", "Courier",, "ArialUnicodeMS"-------------------这些字体是显示出出来的
        //如果所有的字体都显示了   就不在从新添加了
        if index == array.count {
            return
        }

        //初始化一个显示字体的label(我这个方法不是最好的   如果写一个tableview展示会方便一些)
        let labels  = UILabel(frame: CGRect(x: 0 , y: index * 15 + 30, width: Int(UIScreen.main.bounds.size.width), height: 15))
        labels.textAlignment = NSTextAlignment.center//居中
        view.addSubview(labels)//添加

        let dicS = [NSForegroundColorAttributeName : UIColor.randomColor,//文字颜色
            NSStrikethroughStyleAttributeName: 1,//删除线宽度
            NSFontAttributeName : UIFont(name: array[index], size: 8.0)!] as [String : Any]//字体

        //初始化富文本
        let attributedString = NSMutableAttributedString(string: "字体--\(array[index])--", attributes: dicS)

        attributedString.setAttributes(dicS, range:NSMakeRange(0, 1))

        labels.attributedText = attributedString

        index += 1
    }

— demo下载地址 —

https://github.com/383974734/nsParagraphStyle

手懒得毛病何时能克服…………/(ㄒoㄒ)/~~

你可能感兴趣的:(iOS)