Swift语言--简单仿制QQ登录界面
2015-06-29 14:37
447 查看
开发工具:xcode6.32
仿制QQ登录界面,以供iOS开发者参考:
仿制QQ登录界面,以供iOS开发者参考:
#import UIKit class ViewController: UIViewController { var QQnum = UITextField() var passNum = UITextField() override func viewDidLoad() { super.viewDidLoad() self .addAllSubViews() // Do any additional setup after loading the view, typically from a nib. } func addAllSubViews() { var ScreenW = UIScreen.mainScreen().bounds.width print("Hello ,Swift!") /// 头像 var headImage = UIImageView() headImage.frame = CGRectMake(ScreenW/3, 30, 220, 200) headImage.center = CGPointMake(ScreenW/2, 120) // headImage.backgroundColor = UIColor.redColor() headImage.image = UIImage(named: "icon1") self.view.addSubview(headImage) /// 输入qq号 var phoneLab = UILabel(frame: CGRectMake(30, 240, UIScreen.mainScreen().bounds.size.width-60, 30)) phoneLab.text = "请输入QQ号" self.view.addSubview(phoneLab) var QQnum = UITextField() QQnum.frame = CGRectMake(30, 270, UIScreen.mainScreen().bounds.size.width-60, 30) QQnum.placeholder = "请输入QQ号" QQnum.layer.borderWidth = 1 QQnum.layer.borderColor = UIColor.lightGrayColor().CGColor QQnum.layer.cornerRadius = 5 QQnum.keyboardType = UIKeyboardType.NumberPad self.view.addSubview(QQnum) self.QQnum = QQnum /// 密码输入提示 var passText = UILabel(frame: CGRectMake(30, 300, UIScreen.mainScreen().bounds.size.width-60, 30)) passText.text = "请输入密码" self.view.addSubview(passText) /// 密码输入框 var PassNumber = UITextField(frame: CGRectMake(30, 330, UIScreen.mainScreen().bounds.size.width-60, 30)) PassNumber.placeholder = "请输入密码" PassNumber.secureTextEntry = true PassNumber.layer.borderWidth = 1 PassNumber.layer.borderColor = UIColor.lightGrayColor().CGColor PassNumber.layer.cornerRadius = 5 PassNumber.clearButtonMode = UITextFieldViewMode.WhileEditing self.view.addSubview(PassNumber) self.passNum = PassNumber /// 密码找回 var button = UIButton() button.frame = CGRectMake(200, 360, 120, 30) UIButton.buttonWithType(UIButtonType.Custom) button.setTitle("忘记密码", forState: UIControlState.Normal) button.setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal) self.view.addSubview(button) button.addTarget(self, action: "onClick", forControlEvents: UIControlEvents.TouchUpInside) } /// 密码找回方法实现 func onClick(){ ///找回密码提示 UIAlertView(title: "温馨提示", message: "新密码已发送至手机上", delegate: self, cancelButtonTitle: "取消").show() // UIAlertView(title: "温馨提示", message: "新密码已发送至手机上", delegate: nil, cancelButtonTitle: "确定", otherButtonTitles: "取消").show() } /** 点击界面键盘辞去第一响应者 */ override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { self.QQnum.resignFirstResponder() self.passNum.resignFirstResponder() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }
相关文章推荐
- GUI - Web前端开发框架
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 评价ui设计作品好坏的八个标准(界面/交互设计研究)
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- Apple Swift学习教程
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 为Yahoo! UI Extensions Grid增加内置的可编辑器
- Cocos2d-x UI开发之文本类使用实例
- 在IE 浏览器中使用 jquery的fadeIn() 效果 英文字符字体加粗
- UI Events 用户界面事件
- 基于jQuery UI CSS Framework开发Widget的经验
- jquery ui 1.7 ui.tabs 动态添加与关闭(按钮关闭+双击关闭)
- jQuery UI的Dialog无法提交问题的解决方法
- 关于jQuery UI 使用心得及技巧
- jQuery ui 1.7更新小结