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 = 50
textField的左右视图
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<UITouch>, 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)
总结:记不住的代码
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...