importUIKitimportXHToastSwiftclassBindFrameNumAlertVC:BaseAlertVC,UITextFieldDelegate{let textField =UITextField()functextField(_ textField:UITextField, shouldChangeCharactersIn range:NSRange, replacementString string:String)->Bool{// Get the new text after the user enters or deletes characterslet newText =(textField.text asNSString?)?.replacingCharacters(in: range, with: string)??""// Limit the text field to 15 charactersreturn newText.count <=15}overridefuncviewDidLoad(){super.viewDidLoad()centerView.backgroundColor =.whitecenterView.snp.makeConstraints { make inmake.width.equalTo(300)make.height.equalTo(250)make.center.equalToSuperview()}centerView.layer.cornerRadius =10let titleLabel =UILabel()centerView.addSubview(titleLabel)titleLabel.text =LocalizableManager.localValue("binding_frame_number")titleLabel.snp.makeConstraints { make inmake.centerX.equalToSuperview()make.top.equalToSuperview().offset(20)}textField.delegate =selftextField.backgroundColor =UIColor.rgbColor(red:219, green:219, blue:219)textField.keyboardType =.numberPadtextField.textAlignment =.centercenterView.addSubview(textField)textField.snp.makeConstraints { make inmake.centerX.equalToSuperview()make.width.equalTo(220)make.height.equalTo(50)make.top.equalTo(titleLabel.snp_bottom).offset(30)}textField.layer.cornerRadius =10//限制textField只能输入15个字符let alertLabel =UILabel()alertLabel.numberOfLines =0alertLabel.font =UIFont(name:"PingFang SC", size:13)alertLabel.textColor =.grayalertLabel.text =LocalizableManager.localValue("input_corresponding_code")centerView.addSubview(alertLabel)alertLabel.snp.makeConstraints { make inmake.top.equalTo(textField.snp_bottom).offset(10)make.left.equalTo(textField).offset(10)make.right.equalTo(textField)}let sureBtn =UIButton()sureBtn.backgroundColor =UIColor.rgbColor(red:219, green:219, blue:219)sureBtn.setTitleColor(.black,for:.normal)sureBtn.addTarget(self, action:#selector(sureBtnClick),for:.touchUpInside)sureBtn.setTitle(LocalizableManager.localValue("sure"),for:.normal)centerView.addSubview(sureBtn)sureBtn.snp.makeConstraints { make inmake.left.equalToSuperview().offset(30)make.bottom.equalToSuperview().offset(-20)make.width.equalTo(100)make.height.equalTo(40)}sureBtn.layer.cornerRadius =20let cancelBtn =UIButton()cancelBtn.backgroundColor = newUIYellowcancelBtn.addTarget(self, action:#selector(cancelBtnClick),for:.touchUpInside)cancelBtn.setTitle(LocalizableManager.localValue("cancel"),for:.normal)centerView.addSubview(cancelBtn)cancelBtn.snp.makeConstraints { make inmake.right.equalToSuperview().offset(-30)make.bottom.equalToSuperview().offset(-20)make.width.equalTo(100)make.height.equalTo(40)}cancelBtn.layer.cornerRadius =20}@objcfuncsureBtnClick(){print(textField.text)guardlet str = textField.text,str.count ==15else{XHToast.showBottomWithText(LocalizableManager.localValue("input_only_six_num"))return}}@objcfunccancelBtnClick(){}}
7 reference、const、new/delete
7.1 reference
x 是整数,占4字节;p 是指针占4字节(32位);r 代表x,那么r也是整数,占4字节
int x 0;
int* p &x; // 地址和指针是互通的
int& r x;…
本篇将会介绍beutifulsoup4模块,可以用于网络爬虫、解析HTML和XML,对于没有接触过前端,不了解HTML是如何工作的,需要先解释一下什么事HTML。
1. HTML
网页中的各种布局等的背后都是非常简单的纯文本格式,那种格式称为…