Swift: Animation
4 декабря 2016, 15:46
Анимацию элементов сделать довольно не сложно
Скрытие элементов
let step1 = 0.5 let step2 = 1.0 let step3 = 1.5 UIView.animate(withDuration: step1, animations: { self.labelDate.alpha = 0 self.view.layoutIfNeeded() }) UIView.animate(withDuration: step2, animations: { self.labelLevelUP.alpha = 0 self.view.layoutIfNeeded() }) UIView.animate(withDuration: step3, animations: { self.labelLevelDN.alpha = 0 self.view.layoutIfNeeded() })
Показ элементов
func showUI(){ let step1 = 1.0 let step2 = 2.0 let step3 = 3.5 UIView.animate(withDuration: step3, animations: { self.labelDate.alpha = 1 self.view.layoutIfNeeded() }) UIView.animate(withDuration: step2, animations: { self.labelLevelUP.alpha = 1 self.view.layoutIfNeeded() }) UIView.animate(withDuration: step1, animations: { self.labelLevelDN.alpha = 1 self.view.layoutIfNeeded() }) }
просто изменяем прозрачность, иногда можно использовать задержку, в основном потоке чтобы не заморачиваться с дочерними, вызвав функцию sleep(в секундах)
sleep(3)
Перемещение объектов
uiViewedObject.view.center = CGPoint(x,y)
Твитнуть
Поделиться
Поделиться
Популярное