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