swift 基础学习一

swift 基础学习一,第1张

概述1. 利用NSUserDefaults存储用户名和密码 (1)获取用户名和密码 userTextFeild.text = NSUserDefaults.standardUserDefaults().valueForKey("userName") as! String! passWordTextFeild.text = NSUserDefaults.standardUserDefa

1. 利用NSUserDefaults存储用户名和密码

(1)获取用户名和密码

 userTextFeild.text = NSUserDefaults.standardUserDefaults().valueForKey("username") as! String!        passWordTextFeild.text = NSUserDefaults.standardUserDefaults().valueForKey("password") as! String!
(2)存储用户名和密码
// MARK: 点击事件    func loginbuttonClick(sender: UIbutton!)    {        print("UiSlider Vaule: \(sender.tag)")                if userTextFeild.text == "ww" && passWordTextFeild.text == "123456"        {            NSUserDefaults.standardUserDefaults().setobject(userTextFeild.text,forKey: "username")            NSUserDefaults.standardUserDefaults().setobject(passWordTextFeild.text,forKey: "passWord")            NSUserDefaults.standardUserDefaults().synchronize()                        let rootVC = TFTabbarVIEwController()            self.navigationController!.pushVIEwController(rootVC,animated: false)        }                else        {           let alertVIEw = UIAlertVIEw()           alertVIEw.Title = "提示"           alertVIEw.message = "账户或密码输入错误"           //alertVIEw.addbuttonWithTitle("我知道了")           alertVIEw.addbuttonWithTitle("确定")           alertVIEw.cancelbuttonIndex=0           alertVIEw.delegate=self;           alertVIEw.show()        }    }


2. UIbutton 初始化
 let loginbutton = UIbutton(frame: CGRectMake(10,240,300,40))        loginbutton.setTitle("登录",forState:UIControlState.normal)        loginbutton.backgroundcolor = UIcolor.redcolor()        loginbutton.tag = 999        loginbutton.addTarget(self,action: "loginbuttonClick:",forControlEvents: UIControlEvents.touchUpInsIDe)        self.vIEw.addSubvIEw(loginbutton)

3. UIImageVIEw初始化,以及在它上面添加图片
 let backbutton = UIbutton(frame: CGRectMake(0,12,70,44))        backbutton.addTarget(self,action: "backBtn:",forControlEvents: UIControlEvents.touchUpInsIDe)        self.vIEw.addSubvIEw(backbutton)               let arrowVIEw=UIImageVIEw(image:UIImage(named:"icon-driver-zhaohuo-back.png"))       arrowVIEw.frame=CGRectMake(0,50,35)       backbutton.addSubvIEw(arrowVIEw)

4. UILabel初始化
 TitleLable = UILabel(frame: CGRectMake(0,25,self.vIEw.frame.size.wIDth,30))        TitleLable.text = Title as String        TitleLable.textAlignment = NSTextAlignment.Center        TitleLable.Font=UIFont(name:"Thonburi",size:18)        TitleLable.backgroundcolor = UIcolor.clearcolor()        self.navigationVIEw.addSubvIEw(TitleLable);
总结

以上是内存溢出为你收集整理的swift 基础学习一全部内容,希望文章能够帮你解决swift 基础学习一所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1076512.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存