Last active
August 29, 2015 14:12
-
-
Save beelsebob/b4dc1a87dc5c89fc8cfa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidAppear(animated: Bool) { | |
super.viewDidAppear(animated) | |
if self.alreadySearched { | |
return | |
} | |
self.alreadySearched = true | |
self.searchingAnimationView.showMessage2("LOOKING FOR HOTELS\nWITH VACANCIES") { | |
var totalWidth: CGFloat = 0.0 | |
let hotelImageViews: [UIImageView] = (1...5).map { | |
i in | |
let hotelImageView = UIImageView(image: UIImage(named: "ic-hotel-\(i)")!) | |
totalWidth += hotelImageView.bounds.size.width | |
return hotelImageView | |
} | |
var leftPosition = -totalWidth | |
let y = (self.searchingAnimationView.frame.size.height / 2) | |
for hotelImageView in hotelImageViews { | |
hotelImageView.alpha = 0.3 | |
let width = hotelImageView.frame.size.width | |
hotelImageView.center = CGPoint(x: leftPosition + (width / 2), y: y) | |
leftPosition += width | |
self.searchingAnimationView.addSubview(hotelImageView) | |
} | |
func animateHotels() { | |
UIView.animateWithDuration(3, animations: { | |
for hotelImageView in hotelImageViews { | |
hotelImageView.center = CGPoint(x: totalWidth + hotelImageView.center.x, y: hotelImageView.center.y) | |
} | |
}, completion: { | |
finished in | |
if finished { | |
animateHotels() | |
} | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment