zoukankan      html  css  js  c++  java
  • 【swift学习笔记】六.访facebook登录页面

    代码最下边有下载地址。

    做这个demo的主要心得就是自适应所有的屏幕,要先布局大的框架,再一步一步设置小的细节。

    看一下效果

    再看一下自动适应所有屏幕的效果:

     keyboard打开时整个frame上移一个keyboard的高度

     override func viewDidLoad() {
            super.viewDidLoad()
            // Do any additional setup after loading the view, typically from a nib.
            
            // btn
            loginBtn.layer.cornerRadius = 3
            
            // text
            userText.delegate = self
            passwordText.delegate = self
            
            
            NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ViewController.keyboardWillShow(_:)), name: UIKeyboardWillShowNotification, object: nil)
            NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ViewController.keyboardWillHide(_:)), name: UIKeyboardWillHideNotification, object: nil)
    
        }
    
     func keyboardWillShow(notification: NSNotification) {
            if isMovied {
                return
            }
            isMovied = true
            if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
                
                UIView.animateWithDuration(0.25, animations: {
                    self.view.frame.origin.y -= keyboardSize.height
                    }
                )
            }
            
        }
        
        func keyboardWillHide(notification: NSNotification) {
            
            isMovied = false
            if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() {
                UIView.animateWithDuration(0.25, animations: {
                    self.view.frame.origin.y += keyboardSize.height
                })
            }
        }

    别的就没有什么技术点了,大家有时间下载代码看一下吧。

     源代码:FaceBookLoginView.zip

  • 相关阅读:
    A:hover,A:visited 和A:active的区别
    什么是UrlEncode
    ERP系统BOM详细解析(一)
    ERP术语 [转]
    ERP理论的形成
    MRP的計算步驟
    ERP系统模块完全解析──物料编码分章(一)
    Transact SQL 常用语句以及函数
    SQL 2000中的触发器使用
    修改docker0默认IP地址
  • 原文地址:https://www.cnblogs.com/li-peng/p/5584236.html
Copyright © 2011-2022 走看看