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

  • 相关阅读:
    datepicker防手动输入
    [ACM]Link-Cut Tree实现动态树初探
    STL priority_queue 优先队列 小记
    hihoCoder挑战赛1 毁灭者问题
    python编程技巧
    openstack horizon 学习(3) DataTable
    Upcasting, downcasting in JAVA
    SGU 145
    URAL 1003,1004
    自建物流的无人机实验(困难)
  • 原文地址:https://www.cnblogs.com/li-peng/p/5584236.html
Copyright © 2011-2022 走看看