无标题文章

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)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1、设置UILabel行间距 NSMutableAttributedString*attrString=[[NSM...
    iOS祎阅读 6,648评论 0 0
  • swift实现导航栏 funcapplication(application:UIApplication, did...
    青瑄阅读 1,787评论 0 0
  • 转至元数据结尾创建: 董潇伟,最新修改于: 十二月 23, 2016 转至元数据起始第一章:isa和Class一....
    40c0490e5268阅读 5,872评论 0 9
  • 硬着头皮,报名参加了“30天专注成长计划”,突然想起上学期间”作文“的悲惨经历。 我理科好些,语文是我的弱项,作文...
    JEVN阅读 1,603评论 0 0
  • 今天的晨读分享的是斯坦福最受欢迎的沟通课《高效演讲》如何让我们的演讲更有吸引力呢?书中给了三个可以应用到生活中的小...
    AirBlue_9d36阅读 1,369评论 0 1

友情链接更多精彩内容