Skip to content

An Event View based on Apple's Event Detail View. Written in Swift 3. Supports ARC, Autolayout and editing via StoryBoard.

License

Notifications You must be signed in to change notification settings

amantaneja/PTEventView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 

Repository files navigation


An Event View based on Apple's Event Detail View. Written in Swift 3. Supports ARC, Autolayout and editing via StoryBoard.

License Platform Swift 3.x MadeWithLove

Installation

CocoaPods

The project is uploaded on CocoaPods and will available for downloading soon.
http://cocoadocs.org/docsets/PTEventView/0.2.0/

Carthrage

The project will be available on Carthrage too. [As soon as I learn how to do it. ;) ]

Manual

You can drag and drop the Files from here into your projects directly.

Setup

Adding PTEventView

fileprivate weak var myCalenderView: PTEventView!
// In loadView or viewDidLoad
let ptEventView = Bundle.main.loadNibNamed("PTEventView", owner: nil, options: nil)![0] as? PTEventView
ptEventView?.delegate = self
ptEventView?.setup(frame: myCalenderView.frame)
self.view.addSubview(ptEventView!)

Data Model

PTEventView supports both 12 hour and 24 hour format as data model. The input can be received from the API or Database(Core Data, Realm, SQLite) in the form of Array of Event Object.
The Event Object should have:

  • Start Time (12 hour or 24 hour)
  • End Time (12 hour or 24 hour)
  • Name of the Event
    Note: Incase of 12 hour, suffix time with AM or PM.

Example

let dataModel12hour = [["10AM","11AM","Swift Meetup '17"],["12AM","3PM","WWDC KickOff"]]
let dataModel24hour = [["10","11","Swift Meetup '17"],["12","15","WWDC KickOff"]]

Use Bool to switch between Time Formats

ptEventView?.is24HourFormat = true
for event in dataModel12hour{
            
    let eventModel = PTEventViewModel()
    
    eventModel.startTime = event[0]
    eventModel.endTime = event[1]
    eventModel.eventName = event[2]
    
    ptEventView?.EventViewdataModel.append(eventModel)
}

StoryBoard

Supports IBDesignable to alter Border Width, Corner Radius and Border Color

ToDo[s]

  • Add support for PM and AM via 24 hour format
  • Orientation Support. Currently supports UI for Portrait.
  • Add delegation for callbacks
  • Implement AutoLayout for CalenderView
  • Support Events on the same day
  • Add IBInspectable for Row Color of Event

License

PTEventView is released under the MIT license. See LICENSE for details.