本博在iOS原有静态界面的基础上,一步步尝试使用动画来突出选择动作,使原来呆板的元素瞬间鲜活了许多,为用户打造活力满满的界面。
没有动画的世界原来的界面很简单,用户通过段选择器(UISegmentedControl)来选择切换两个不同的UILabel,如下所示:
由上至下两个UILabel为curFromDateLbl和curToDateLbl,分别代表起始日期和结束日期,我专门写了一个方法来完成Label的切换:
///更新选择Label的界面 private func updateUIForSelectLbl(_ lbl:UILabel){ lbl.textColor = .white lbl.backgroundColor = UIColor.slateGray() lbl.layer.shadowColor = UIColor.darkGray.cgColor lbl.layer.shadowOffset = CGSize(width: 3, height: 3) lbl.layer.shadowOpacity = 0.8 lbl.layer.shadowRadius = 5.0 if lbl == curFromDateLbl{ curToDateLbl.textColor = .black curToDateLbl.backgroundColor = .white curToDateLbl.layer.shadowOpacity = 0.0 }else{ curFromDateL