QVRWeekView is a work in progress framework that contains a week/day view that allows you to display, add and remove events.
- Horizontal and vertical scrolling
- Infinite horizontal scrolling
- Colour, size and font customization features
- Day and hour label font resizing
- Dynamic event adding and removing
- Event tap, long press and event request callbacks
- Number of visible days customizable
To run the example project, clone the repo, and run
pod install from the Example directory first.
Most useful example code can be found in
Example > QVRWeekView > CalendarViewController or StartViewController
This pod requires a minimum deployment target of iOS 9.0.
QVRWeekView is available through CocoaPods. To install it, simply add the following line to your Podfile:
Once the framework is installed, there are two ways you can incorporate the
WeekView into your project:
To add the WeekView programatically, simply import
QVRWeekView into your code by adding:
at the top of your source file containing your view controller. Then insert the WeekView into your view controller by adding:
let weekView = WeekView(frame: self.view.frame) self.view.addSubview(weekView)
into either your viewDidLoad or viewWillAppear method.
2. Via the storyboard
To add the
WeekView via the storyboard, simply add a View onto your View Controller and resize it or add constraints. Then go to the identity inspector of your view and select the Class to be
WeekView and the module to be
QVRWeekView (See image).
Then you should be all set!
Working with WeekView
WeekView has a delegate called
WeekViewDelegate. For now this delegate contains only three functions:
||Called when a dayView column is long pressed. The passed
||Use this function to add individual user events|
||Called when an event is tapped.
||Use this function to prompt event editing or removal|
||Called when events are ready to be loaded.
||Use this function to load in stored events|
WeekView Public functions
||Updates the time displayed by the hour indicator|
||Scrolls the week view to the day passed by
||Scrolls the week view to today|
||Loads, processes and displays the events provided by the
EventData is the main object used to communicate events between the WeekView and your code. EventData can be overriden.
||A unique identifier for this event|
||A title that will be displayed for this event|
||The start date for this event|
||The end date for this event|
||The main color for this event|
||Indicates if this event is an all day event, all day events are displayed along the top bar|
|configureGradient()||Used to configure a gradient that will be used to render your event instead of just a solid color|
Below is a table of all customizable properties of the
||Sets spread all day events on x axis, if not true than spread will be made on y axis.|
How it works
The main WeekView view is a subclass of UIView. The view layout is retrieved from the WeekView xib file. WeekView contains a top and side bar sub view. The side bar contains an HourSideBarView which displays the hours. WeekView also contains a DayScrollView (UIScrollView subclass) which controls vertical scrolling and also delegates and contains a DayCollectionView (UICollectionView subclass) which controls the horizontal scrolling. DayCollectionView cells are DayViewCells, whose view is generated programtically (due to inefficiencies caused by auto-layout).
WeekView handles all top level operations such as pinch gestures and orientation change. Scrolling of the top and side bar is handled by a function inside of WeekView which is called by the DayScrollView when scrolling. Top bar day labels are generated, displayed and discarded simulaneously with DayCollectionView cells by the WeekView.
- Ability to add and remove events
- Event color customization
- Extra customization features
- Improved UI features
- Increased event processing efficiency
- Add scroll to all day events
Reinert Lemmens, [email protected]
QVRWeekView is available under the MIT license. See the LICENSE file for more info.