         }
         self.eventLayers.removeAll()
 
-        var factorChange = CGFloat(1)
-        let newHeight = self.frame.height
-        if prevHeight == nil {
-            prevHeight = newHeight
-        }
-        else {
-            factorChange = newHeight / prevHeight!
-        }
+        var scaleY = CGFloat(1)
+
+        scaleY = self.frame.height/prevHeight
+        prevHeight = self.frame.height
 
         // Generate event rectangle shape layers and text layers
         for (id, frame) in self.eventFrames {

    private var seperatorLayers: [CAShapeLayer] = []
    // Event rectangle shape layers
    private var eventLayers: [CALayer] = []
    // PRevious height
    private var prevHeight: CGFloat?

    // Delegate variable
    weak var delegate: DayViewCellDelegate?

            guard eventsData[id] != nil else {
                return
            }
            let transform = CGAffineTransform(scaleX: 1.0, y: scaleY)
            var newFrame = frame
            if scaleY != 1.0 {
                self.eventFrames[id] = frame.applying(transform)
                newFrame = self.eventFrames[id]!
            }

            let eventRectLayer = CAShapeLayer()
            eventRectLayer.path = CGPath(rect: newFrame, transform: nil)
            eventRectLayer.fillColor = eventsData[id]!.color.cgColor

            let eventTextLayer = CATextLayer()
            eventTextLayer.frame = newFrame
            eventTextLayer.string = eventsData[id]!.title
            let font = FontVariables.eventLabelFont
            let ctFont: CTFont = CTFontCreateWithName(font.fontName as CFString, font.pointSize, nil)
