Learn iOS and ios

Source: Internet
Author: User

Learn iOS and ios

Continue to make the second copy of others

1. First download some fonts and search for "Word Building Studio" online"

2. Put the downloaded font file into the project, and it will be OK.

Not to mention, the effect is as follows:

You can use the following method to retrieve all fonts in the project:

   for family in UIFont.familyNames {                        for font in UIFont.fontNames(forFamilyName: family) {                                print(font)                            }                    }

The Code is as follows:

Import UIKitclass ViewController: UIViewController {lazy var contentLabel = UILabel () lazy var changeBtn = UIButton () var tag: Int = 0 override func viewDidLoad () {super. viewDidLoad ()/* for family in UIFont. familyNames {for font in UIFont. fontNames (forFamilyName: family) {print (font) }}*/self. view. backgroundColor = UIColor. black contentLabel. frame = CGRect (x: 10, y: 20, width: UIScreen. main. bounds. size. width-20, height: 200) contentLabel. numberOfLines = 0 contentLabel. textColor = UIColor. white contentLabel. font = UIFont. systemFont (ofSize: 20) self. view. addSubview (contentLabel) let content: string = "30 Days Swift \ n currently authorized individuals are free of charge for non-commercial use \ n, So I donated 1 yuan and 3 fonts for testing \ n, respectively. work room Jin Hei, to the Black and childlike innocence; "contentLabel. text = content changeBtn. backgroundColor = UIColor. orange changeBtn. frame. size = CGSize (width: 100, height: 100) changeBtn. frame. origin = CGPoint (x: UIScreen. main. bounds. size. width/2-50, y: UIScreen. main. bounds. size. height-120) changeBtn. setTitle ("Change font", :. normal) changeBtn. layer. masksToBounds = true changeBtn. layer. cornerRadius = 50.0 changeBtn. addTarget (self, action: # selector (changeFont), :. touchUpInside) self. view. addSubview (changeBtn)} // MARK:-Click Event func changeFont () {var fontName: String switch tag {case 0: fontName = "MFQingShu_Noncommercial-Regular" tag = 1 case 1: fontName = "MFYueYuan_Noncommercial-Regular" tag = 2 case 2: fontName = "MFWenYan_Noncommercial-Regular" tag = 3 default: fontName = "AppleSDGothicNeo-Regular" tag = 0} contentLabel. font = UIFont. init (name: fontName, size: 20)} override func didReceiveMemoryWarning () {super. didReceiveMemoryWarning () // Dispose of any resources that can be recreated .}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.