Skip to content

Instantly share code, notes, and snippets.

@ryanmcgrath
Created December 3, 2018 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanmcgrath/61a1d5f28d93ce6042a2442097a38ce3 to your computer and use it in GitHub Desktop.
Save ryanmcgrath/61a1d5f28d93ce6042a2442097a38ce3 to your computer and use it in GitHub Desktop.
class HolidayCalendarCollectionViewItem: NSCollectionViewItem {
var leftAnchor: NSLayoutConstraint?
var initialTouchOne: NSTouch?
var initialTouchTwo: NSTouch?
var currentTouchOne: NSTouch?
var currentTouchTwo: NSTouch?
var initialPoint: CGPoint?
var isTracking = false
public lazy var contentView: NSView = {
let view = NSView(frame: .zero)
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
override func loadView() {
let itemView = NSView(frame: .zero)
itemView.postsFrameChangedNotifications = false
itemView.postsBoundsChangedNotifications = false
itemView.wantsLayer = true
itemView.allowedTouchTypes = [.direct, .indirect]
itemView.addSubview(contentView)
leftAnchor = contentView.leftAnchor.constraint(equalTo: itemView.leftAnchor)
NSLayoutConstraint.activate([
contentView.topAnchor.constraint(equalTo: itemView.topAnchor),
leftAnchor!,
contentView.bottomAnchor.constraint(equalTo: itemView.bottomAnchor),
contentView.widthAnchor.constraint(equalTo: itemView.widthAnchor),
])
view = itemView
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment