Self-study IOS-30 days 30 Swift projects the next day

Source: Internet
Author: User

Keep doing the second one that mimics someone else.

1. First download some fonts online search "word-type workshop"

2. Put the downloaded font file into the project and it's OK.

Not much to say the effect is as follows

The following method can be used to retrieve all the fonts in the project

    for inch uifont.familynames {                        for in  uifont.fontnames (forfamilyname:family) {                                print ( Font)                            }                    }

The code is as follows

Import UIKitclassViewcontroller:uiviewcontroller {lazy var contentlabel=UILabel () lazy var changebtn=UIButton () var tag:int=0            Overridefunc 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:TenY: -, Width:UIScreen.main.bounds.size.width- -, Height: $) Contentlabel.numberoflines=0Contentlabel.textcolor=Uicolor.white Contentlabel.font= Uifont.systemfont (ofsize: -) Self.view.addSubview (Contentlabel) let content:string="swift\n\n currently authorized personal free non-commercial use \ n \ nyou donated 1 yuan under the 3 font used to do the experiment \ n, respectively, is the word-making workshop black, black and childlike innocence;"Contentlabel.text=content Changebtn.backgroundcolor=Uicolor.orange changeBtn.frame.size= Cgsize (width: -, Height: -) ChangeBtn.frame.origin= Cgpoint (x:uiscreen.main.bounds.size.width/2- -, Y:uiscreen.main.bounds.size.height- -) Changebtn.settitle ("Change Font", for:. Normal) ChangeBtn.layer.masksToBounds=trueChangeBtn.layer.cornerRadius=50.0Changebtn.addtarget (Self, Action: #selector (Changefont), for:. Touchupinside) Self.view.addSubview (CHANGEBTN)}//MARK:-click eventsfunc Changefont () {var fontname:stringSwitchTag { 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: -)    }            Overridefunc didreceivememorywarning () {super.didreceivememorywarning ()//Dispose of any resources the can be recreated.    }}

Self-study IOS-30 days 30 Swift projects the next day

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.