A mini week view to select a day. You can swipe through weeks and tap on a day to select them, somewhat similar to the iOS calendar app (since iOS 7).
It's using the methodology described in Apple's excellent WWDC 2011 session 104 "Advanced ScrollView Techniques".
- Add to your project.
Using Swift Package Manager:
.package(url: "https://github.com/nighthawk/ASWeekSelectorView.git", from: "1.0.0")
Using Cocoapods:
pod 'ASWeekSelectorView', '~> 1.0'
-
Add an instance of
ASWeekSelectorView
to your view hierarchy, configure it, provide a delegate and implement the delegate smethod. (Note that you won't need to useASDaySelectionView
andASSingleWeekView
yourself - they are internal helper class.) -
When using Auto Layout, adjust the frame in
viewWillLayoutSubviews
:
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
weekSelector.frame.size.width = self.view.frame.width
}
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
CGRect frame = self.weekSelector.frame;
frame.size.width = CGRectGetWidth(self.view.frame);
self.weekSelector.frame = frame;
}
See the included example project for a very basic implementation.