1.swift How can I hide the QuickType keyboard toolbar on my IPad?
Let item = textfield.inputassistantitem = [Uibarbuttonitemgroup] () = [ Uibarbuttonitemgroup] () =. No
2.dismiss Current controller Jump:
@IBAction Func Custommoneyclick (_ Sender:any) { true) {self . delegate? . Gotocustommoney () } }
3. Custom Jump Controller:
Init (Withtype type:loginorregistertype) { = type super.init (Nibnam.e:nil, Bundle:nil) = . Custom }
4. Regular judgment:
Fileprivate Func Isvalideregistername (_ registername:string)Bool {Let Parttenprefix="^[a-za-z\\u4e00-\\u9fa5]{1}.*" //The first letter cannot be a numberLet Parttenvalidechar ="^[a-za-z0-9\\u4e00-\\u9fa5_]+$" //illegal characters only allow letters, Chinese characters, numbers, underscoresLet Parttenlength ="^[a-za-z0-9\\u4e00-\\u9fa5_]{2,16}$" //length 2-16 varpredicate = nspredicate (format:"Self MATCHES%@", Parttenprefix)if!predicate.evaluate (with:registername) {hudmanager.showautodismissfailedmessage (Global_language ("nickname initials can only be letters or kanji! ")) return false }}
5.CollectionView achieves the lowest vertical interval:
Let layout = uicollectionviewflowlayout () 3.0 = cgfloat.leastnormalmagnitude
6.button.isexclusivetouch = True
Exclusivetouch's role is to avoid bugs by achieving exclusivity when multiple controls on the same interface accept events. In other words, avoiding multiple uibutton at the same time on one interface causes multiple methods to respond simultaneously. Use this to control the Exclusivetouch property of the UIButton, which needs to be set on each controller. Use a word instead of this setting to add [[UIButton appearance] setexclusivetouch:yes] When Appdelegate launches the app;
7.Kingfisher Settings Picture:
BackgroundImageView.kf.setImage (With:url (string: imageurlstr), placeholder:uiimage (named: " Qianrenqianwei " ), options: [. Transition (Imagetransition.fade (1)),. Keepcurrentimagewhileloading])
8.super.init () method before writing the difference:
First write is to go first the parent class initialization method, put in the back, will handle the class of overrides, preferably written in front.
9.UIStackView Code Usage:
Let Stackview:uistackview = { = Uistackview (frame:CGRect.zero) =. Horizontal // the layout direction of the child view view.alignment =. Center // child view Alignment view.distribution =. fillequally // sub-view distribution scale (size) the height or width of each child view remains the same. return View } ()
10.isEmpty function:
//create an empty string using string literalsvarStringa =""ifstringa.isempty {print ("Stringa is empty." )} Else{print ("Stringa is not empty." )}//instantiate the string class to create an empty stringLet STRINGB =String ()ifstringb.isempty {print ("stringb is empty." )} Else{print ("stringb is not empty.")} output: Stringa is empty stringb is empty
Swift Code Summary 2