diff --git a/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift b/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift index dccefbe1..7a1d800f 100644 --- a/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift +++ b/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift @@ -60,13 +60,13 @@ class SkillHomeViewController: CustomNavigationBarViewController { willSet { switch newValue { case .Master: - headerView.learningButton.setInActive() - headerView.masterButton.setActive() + headerView.learningButton.setInActive(animated: !isFirstAppear) + headerView.masterButton.setActive(animated: !isFirstAppear) skillHomeScrollView.setContentOffset(CGPoint(x: 0, y: 0), animated: true) case .Learning: - headerView.masterButton.setInActive() - headerView.learningButton.setActive() + headerView.masterButton.setInActive(animated: !isFirstAppear) + headerView.learningButton.setActive(animated: !isFirstAppear) skillHomeScrollView.setContentOffset(CGPoint(x: masterTableView.frame.size.width, y: 0), animated: true) } @@ -203,6 +203,12 @@ class SkillHomeViewController: CustomNavigationBarViewController { } customTitleView() + + if isFirstAppear { + state = preferedState ?? .Master + + isFirstAppear = false + } } override func viewDidLayoutSubviews() { @@ -223,16 +229,6 @@ class SkillHomeViewController: CustomNavigationBarViewController { self.navigationController?.setNavigationBarHidden(false, animated: true) } - override func viewDidAppear(animated: Bool) { - super.viewDidAppear(animated) - - if isFirstAppear { - isFirstAppear = false - - state = preferedState ?? .Master - } - } - // MARK: UI func customTitleView() { diff --git a/Yep/Views/SkillHomeHeaderView/SkillHomeHeaderView.swift b/Yep/Views/SkillHomeHeaderView/SkillHomeHeaderView.swift index 23ff21c9..c7a5b74d 100644 --- a/Yep/Views/SkillHomeHeaderView/SkillHomeHeaderView.swift +++ b/Yep/Views/SkillHomeHeaderView/SkillHomeHeaderView.swift @@ -74,8 +74,6 @@ class SkillHomeHeaderView: UIView { override func layoutSubviews() { super.layoutSubviews() - masterButton.setActive() - headerImageView.frame = self.bounds masterButton.frame = CGRectMake(0, self.frame.height - YepConfig.skillHomeHeaderButtonHeight, self.frame.size.width/2.0, YepConfig.skillHomeHeaderButtonHeight) diff --git a/Yep/Views/SkillHomeSectionButton/SkillHomeSectionButton.swift b/Yep/Views/SkillHomeSectionButton/SkillHomeSectionButton.swift index e9285be1..734b84b1 100644 --- a/Yep/Views/SkillHomeSectionButton/SkillHomeSectionButton.swift +++ b/Yep/Views/SkillHomeSectionButton/SkillHomeSectionButton.swift @@ -15,24 +15,48 @@ class SkillHomeSectionButton: UIButton { let highLight = CALayer() - func setActive() { - - UIView.animateWithDuration(0.7, delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.5, options: nil, animations: { + func setActive(#animated: Bool) { + + let setting: () -> Void = { self.highLight.frame = CGRectMake(0, self.frame.size.height - skillHeomSectionButtonLineHeight, self.frame.size.width, skillHeomSectionButtonLineHeight) self.highLight.backgroundColor = UIColor.yepTintColor().CGColor - }, completion: nil) + + println("highLight.frame: \(self.highLight.frame)") + } + + if animated { + UIView.animateWithDuration(0.7, delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.5, options: nil, animations: { + + setting() + + }, completion: nil) + + } else { + setting() + } } - func setInActive() { + func setInActive(#animated: Bool) { - UIView.animateWithDuration(0.5, delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.5, options: nil, animations: { + let setting: () -> Void = { self.highLight.frame = CGRectMake(0, self.frame.size.height - skillHeomSectionButtonLineHeight, self.frame.size.width, skillHeomSectionButtonLineHeight) self.highLight.backgroundColor = UIColor.yepDisabledColor().CGColor - }, completion: nil) + } + + if animated { + UIView.animateWithDuration(0.5, delay: 0.0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.5, options: nil, animations: { + + setting() + + }, completion: nil) + + } else { + setting() + } } func updateHightLightBounce() { - highLight.frame = CGRectMake(0, self.frame.size.height - skillHeomSectionButtonLineHeight, self.frame.size.width, 0) + highLight.frame = CGRectMake(0, self.frame.size.height - skillHeomSectionButtonLineHeight, self.frame.size.width, skillHeomSectionButtonLineHeight) } }