无标题文章

2016-09-13  本文已影响0人  写啥呢

return 没写在最后  return后面的代码会执行 //定制navigationBar        //1.设置背景颜色        self.navigationBar.barTintColor = UIColor.blackColor()                //2.设置中间的文字颜色        //NSForegroundColorAttributeName 文字颜色的key        self.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()]                //3.设置填充颜色        self.navigationBar.tintColor = UIColor.whiteColor() //设置状态栏的颜色为白色        UIApplication.sharedApplication().statusBarStyle = .LightContent//        设置背景图片//        以图片路径的方式获取图片        bgImgView =  UIImageView.init(frame: self.view.bounds)        bgImgView.image = UIImage.init(contentsOfFile: NSBundle.mainBundle().pathForResource(bgImgName, ofType: nil)!)//        设置中间segement        let segement = UISegmentedControl.init(items: ["消息","电话"])        segement.frame = CGRectMake(0, 0, 100, 40)        segement.selectedSegmentIndex = 0//        设置segement边框颜色        segement.layer.borderColor = UIColor.whiteColor().CGColor        segement.layer.borderWidth = 1//        设置segement背景颜色//        segement.backgroundColor = UIColor.whiteColor()        segement.tintColor = UIColor.whiteColor()                        self.navigationItem.titleView = segement按钮切圆 //切圆        self.centerBtn.layer.masksToBounds = true        self.centerBtn.layer.cornerRadius = 50textField的左右视图let leftImageView1 = UIImageView.init(frame: CGRectMake(0, 0, 40, 50))        leftImageView1.contentMode = .Center        leftImageView1.image = UIImage.init(named: "user")        userField.leftView = leftImageView1        userField.leftViewMode = .Always        self.bgView.addSubview(userField)        userField.delegate = self override func touchesBegan(touches: Set, withEvent event: UIEvent?) {

//        self.outHandAnimation()

self.view.endEditing(true)

}

//MARK: - 监听键盘的弹起和收起

extension LoginViewController{

func addObserverAction() {

//当键盘弹起和收起的时候,系统会自动通过消息中心去发送相应的消息。

//UIKeyboardWillShowNotification -> 键盘将要弹起对应的消息名

//UIKeyboardWillHideNotification -> 键盘将要收起对应的消息名

NSNotificationCenter.defaultCenter().addObserver(self, selector: "showKeyBoard:", name: UIKeyboardWillShowNotification, object: nil)

NSNotificationCenter.defaultCenter().addObserver(self, selector: "hideKeyBoard:", name: UIKeyboardWillHideNotification, object: nil)

}

//键盘弹起

func showKeyBoard(nof:NSNotification){

UIView.animateWithDuration(0.4) {

self.bgView.transform = CGAffineTransformMakeTranslation(0, -110)

}

}

//键盘收起

func hideKeyBoard(nof:NSNotification) {

UIView.animateWithDuration(0.4) {

self.bgView.transform = CGAffineTransformMakeTranslation(0, 0)

}

}

let story = UIStoryboard.init(name: "Register", bundle: nil)

let register = story.instantiateInitialViewController()

self.navigationController?.pushViewController(register!, animated: true)

上一篇下一篇

猜你喜欢

热点阅读